#pragma once

#include "BuffEffectLogic.h"
#include "BuffEffectInterface.h"
#include "Character/Creature.h"
#include "Character/SkillPart.h"
#include "Character/monster/MonsterMgr.h"
#include "Common/TableData/SkillSkillCfg.h"

#include "Scene/MapMgr.h"
#include "ProtoBuffer/AllProtocol.h"
#include "Character/SkillPart.h"
#include "Character/CollectPart.h"
#include "Character/DeputyPart.h"
#include "Skill/SkillBase.h"
#include "Character/BuffPart.h"
#include "Character/newAI/behaviac/CreatureCommonAI.h"
#include "Character/CreatureMgr.h"
#include "Common/AttrMgr/AttrMgr.h"
#include "Character/npc/Npc.h"
#include "Character/horse/HorsePart.h"

/*
=======================================================================================================================
说明
BuffLogic_000_None ;
功能描述：没有实际的逻辑
参数描述：无
应用举例：
备注:无
=======================================================================================================================
*/
class BuffLogic_000_None  : public IBuffLogic
{
public:
	enum { ID = effectTypeNone, };
	BuffLogic_000_None()
	{

	}
	~BuffLogic_000_None()
	{

	}
};

/*
=======================================================================================================================
说明
BuffLogic_001_DisperseMark ;
功能描述：驱散mark 在buff bag 层次处理， 这里什么都不做
参数描述：无
应用举例：
备注:无
=======================================================================================================================
*/
class BuffLogic_001_DisperseMark : public IBuffLogic
{
public:
	enum { ID = effectTypeDisperseMark, };
	BuffLogic_001_DisperseMark()
	{

	}
	~BuffLogic_001_DisperseMark()
	{

	}
};

/*
=======================================================================================================================
说明
BuffLogic_002_ImmuneMark ;
功能描述：免疫（数据填写为驱散的buff类型32位掩码，持续时间）
参数描述：无
应用举例：
备注:无
=======================================================================================================================
*/
class BuffLogic_002_ImmuneMark : public IBuffLogic
{
public:
	enum { ID = effectTypeImmuneMark, };
	BuffLogic_002_ImmuneMark()
	{

	}
	~BuffLogic_002_ImmuneMark()
	{

	}
};

/*
=======================================================================================================================
说明
BuffLogic_003_ContinuanceDamage ;
功能描述：持续伤害
参数描述：伤害的值，持续时间，间隔时间，形式1：skilllevel*a+b，形式2：最大生命值或最大魔法值*(skilllevel*a+b)，形式3：当前生命值或当前魔法值*(skilllevel*a+b)
应用举例：
备注:无
=======================================================================================================================
*/
class BuffLogic_003_ContinuanceDamage : public IBuffLogic
{
public:
	enum { ID = effectTypeContinuanceDamage, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_003_ContinuanceDamage()
	{

	}
	~BuffLogic_003_ContinuanceDamage()
	{

	}
public:
	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		if (buffInfo.m_param.size() > 0)
		{
			//这里是ms
			pBuff->SetIntervalTime(buffInfo.m_param[0]);
		}
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		//LogInfoFmtPrint("Creature Cid: %d, intervalTime:%d, continuanceTime:%d,OnEvent_Active: value = %d",
		//	pRecv->GetCid(), pBuff->GetIntervalTime(),pBuff->GetContinuanceTime(),value);

		pRecv->AddAttr(C_HP, -1 * (int64_t)value, false, pBuff->GetSenderId());

		if (pRecv->CreatureKind() == CREATURE_MONSTER || pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (pRecv->GetAiData())
			{
				pRecv->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  value);
			}
		}

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_HP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_HP));

		//跳字表现数据
		DigPerfor* pdigti = pTarget->add_digperfors();
		pdigti->set_type(DigPerfor_Type_reduceHp);
		pdigti->set_value(value);

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};
};

/*
=======================================================================================================================
说明
BuffLogic_004_Dizzy ;
功能描述：4-眩晕(持续时间，单位毫秒）
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_004_Dizzy : public IBuffLogic
{
public:
	enum { ID = effectTypeDizzy, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_004_Dizzy(){};
	~BuffLogic_004_Dizzy(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		//SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		pRecv->AddBuffState(CREATURE_BUFF_STATE_DIZZY);
		pRecv->StopMove(false);

		if (pRecv->CreatureKind() == CREATURE_MONSTER || pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (pRecv->GetAiData())
			{
				pRecv->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  0);
			}
		}

	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CREATURE_BUFF_STATE_DIZZY);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_005_Frozen ;
功能描述：5-冰冻（持续时间，单位毫秒）
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_005_Frozen : public IBuffLogic
{
public:
	enum { ID = effectTypeFrozen, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_005_Frozen(){};
	~BuffLogic_005_Frozen(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		//SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		pRecv->AddBuffState(CREATURE_BUFF_STATE_FROZEN);
		pRecv->StopMove(false);

		if (pRecv->CreatureKind() == CREATURE_MONSTER || pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (pRecv->GetAiData())
			{
				pRecv->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  0);
			}
		}
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CREATURE_BUFF_STATE_FROZEN);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_006_Winding ;
功能描述：6-缠绕（持续时间，单位毫秒）
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_006_Winding : public IBuffLogic
{
public:
	enum { ID = effectTypeWinding, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_006_Winding(){};
	~BuffLogic_006_Winding(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		//SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		pRecv->AddBuffState(CREATURE_BUFF_STATE_WINDING);
		pRecv->StopMove(false);

		if (pRecv->CreatureKind() == CREATURE_MONSTER || pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (pRecv->GetAiData())
			{
				pRecv->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  0);
			}
		}
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CREATURE_BUFF_STATE_WINDING);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_007_HpShield ;
功能描述：7-护盾
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_007_HpShield : public IBuffLogic
{
public:
	enum { ID = effectTypeHpShield, };
	enum BuffEffectParamIndex { IDX_PARAM_HP_SHIELD = 0, };
	BuffLogic_007_HpShield(){};
	~BuffLogic_007_HpShield(){};

	virtual int32_t GetShieldHp(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM_HP_SHIELD);
	};

	virtual void SetShiledHp(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM_HP_SHIELD, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		if (param > 0)
		{
			SetShiledHp(pBuff, param);
		}
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->AddBuffState(CREATURE_BUFF_STATE_HP_SHIELD);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CREATURE_BUFF_STATE_HP_SHIELD);
	}

	virtual void OnEvent_ReduceDamage(BuffEffectInfo* pBuff, Creature* pRecv, Creature* pAttack, uint32_t skillId, int32_t &damage) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (damage <= 0)
		{
			return;
		}

		int32_t hpShield = GetShieldHp(pBuff);

		if (hpShield > damage)
		{
			hpShield -= damage;
			damage = 0;
		}
		else
		{
			damage -= hpShield;
			hpShield = 0;
		}

		SetShiledHp(pBuff, hpShield);

		if (hpShield <= 0)
		{
			pBuff->GetBuffBag()->BuffEffect_OnEffectFadeOut();
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_008_TargetMove ;
功能描述：8-击退
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_008_TargetMove : public IBuffLogic
{
public:
	enum { ID = effectTypeTargetMove, };
	enum BuffEffectParamIndex { IDX_PARAM_DICT = 0, };
	BuffLogic_008_TargetMove(){};
	~BuffLogic_008_TargetMove(){};

	virtual int32_t GetParamDict(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM_DICT);
	};

	virtual void SetParamDict(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM_DICT, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		if (param > 0)
		{
			SetParamDict(pBuff, param);
		}
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		Scene* pScene = pRecv->GetScene();
		if (pScene == nullptr)
		{
			return;
		}

		Creature* pSend = pScene->GetCreature(pBuff->GetSenderId());
		if (pSend == nullptr)
		{
			return;
		}

		uint32_t skillId = pBuff->GetSkillId();
		SkillPart* pSkillPart = dynamic_cast<SkillPart*>(pSend->GetPart(PART_SKILL));
		if (pSkillPart == nullptr)
		{
			return;
		}

		Point3<float> srcPos = pRecv->GetPos();

		//float dirDict = point2Length(pRecv->GetPos(), pSend->GetPos());
		Point3<float> dir = pRecv->GetPos() - pSkillPart->GetCreaturePreSkillPos(skillId);
		dir.y = 0;
		if (dir.length()<=0.1)
		{
			LogDebugFmtPrint(" dir.length()<=0.1 ");
			dir = pSkillPart->GetSkillDir(skillId);
			if (dir.length() != 0)
				dir = dir / dir.length();
			else
				dir = pSend->GetDir();
		}
		else
		{
			dir = dir / dir.length();
		}

		float dict = GetParamDict(pBuff)/1000.0f;

		Point3<float> targetPos = srcPos;

		Map* pMap = g_GetMapMgr()->GetMap(pRecv->GetMapId());
		bool ret = false;
		if (pMap)
		{
			for (float d = 0; d <= dict; d += 0.1f)
			{
				Point3<float> tmpPos = srcPos + dir * d;
				Point3<float> tmpTargetPos;
				ret = pMap->FindNearestPos(tmpPos.x, tmpPos.z, tmpPos.y, &tmpTargetPos.x, &tmpTargetPos.z, &tmpTargetPos.y, nullptr);
				if (ret)
				{
					targetPos = tmpTargetPos;
				}
				else
				{
					break;
				}
			}
		}

		pRecv->StopMove();
		pRecv->BeatBack(targetPos);
//			auto pAiData = pRecv->GetAiData();
//			if (pAiData)
//			{
//				pAiData->DelayedLastAiTime(200); //击退延时
//			}

		if (pRecv->CreatureKind() == CREATURE_MONSTER || pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (pRecv->GetAiData())
			{
				pRecv->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  0);
			}
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_009_Invisible ;
功能描述：9-隐身
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_009_Invisible : public IBuffLogic
{
public:
	enum { ID = effectTypeInvisible, };
	BuffLogic_009_Invisible(){};
	~BuffLogic_009_Invisible(){};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		pRecv->AddBuffState(CREATURE_BUFF_STATE_INVISIBLE);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CREATURE_BUFF_STATE_INVISIBLE);

		//现身是怪物攻击
		Scene* pScene = pRecv->GetScene();
		if (pScene == nullptr)
		{
			return;
		}

		std::list<CharIDType> seeLst;
		pRecv->FindCreatureInScene(seeLst);

		for (auto it = seeLst.begin(); it != seeLst.end(); it++)
		{
			uint32_t cid = *it;
			if (cid == pRecv->GetCid())
			{
				continue;
			}

			Creature* pCreature = pScene->GetCreature(cid);
			if (pCreature && pCreature->IsDead() == false && pCreature->CreatureKind() == CREATURE_MONSTER)
			{
				Monster* pMonster = dynamic_cast<Monster*>(pCreature);
				if (pMonster && pMonster->GetMonsterFightType() == ENUM_MONSTER_FIGHT_TYPE_ACTIVE_ATTACK && pMonster->IsFriendSide(pRecv) == false)
				{
					float dict = point2LengthSquare(pRecv->GetPos(), pMonster->GetPos());
					if (dict < pMonster->GetSightRange()*pMonster->GetSightRange())
					{
						CreatureCommonAI* pAIData = pMonster->GetAiData();
						if (pAIData)
						{
							pAIData->AddHateTarget(pRecv->GetCid(), 0, 0);
						}
					}
				}
			}
			else if (pCreature && pCreature->IsDead() == false && pCreature->CreatureKind() == CREATURE_NPC)
			{
				Npc* pNpc = dynamic_cast<Npc*>(pCreature);
				if (pNpc && pNpc->IsFriendSide(pRecv) == false)
				{
					float dict = point2LengthSquare(pRecv->GetPos(), pNpc->GetPos());
					if (dict < pNpc->GetSightRange()*pNpc->GetSightRange())
					{
						CreatureCommonAI* pAIData = pNpc->GetAiData();
						if (pAIData)
						{
							pAIData->AddHateTarget(pRecv->GetCid(), 0, 0);
						}
					}
				}
			}
			else if (pCreature && pCreature->IsDead() == false && pCreature->CreatureKind() == CREATURE_REBOT)
			{
				CreatureCommonAI* pAIData = pCreature->GetAiData();
				if (pAIData)
				{
					pAIData->AddHateTarget(pRecv->GetCid(), 0, 0);
				}
			}
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_010_RefixSkill ;
功能描述：10-修改普工技能
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_010_RefixSkill : public IBuffLogic
{
public:
	enum { ID = effectTypeRefixSkill, };
	enum BuffEffectParamIndex { IDX_PARAM_NEW_SKILL_ID = 0,IDX_PARAM_OLD_SKILL_ID = 1, IDX_PARAM_SKILL_LEVEL = 2, IDX_PARAM_NEW_SKILL_COUNT = 3,};
	BuffLogic_010_RefixSkill(){};
	~BuffLogic_010_RefixSkill(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		if (g_GetSkillSkillCfgTable()->GetSkillSkillCfgInfo(param) == nullptr)
		{
			LogErrFmtPrint("BuffLogic_010_RefixSkill:  skillId:%d is not exist cfg", param);
			return false;
		}

		if (pRecv == nullptr)
			return false;

		SkillPart* pSkillPart = static_cast<SkillPart*>(pRecv->GetPart(PART_SKILL));
		if (pSkillPart)
		{
			if (pSkillPart->GetSkillInfo(param) != nullptr)
			{
				//玩家已经有有该技能
				LogErrFmtPrint("BuffLogic_010_RefixSkill:  creature has the skillId:%d", param);
				return false;
			}
		}

		SetParamValue(pBuff, IDX_PARAM_NEW_SKILL_ID, param);
		if (buffInfo.m_param.size() > 0)
		{
			SetParamValue(pBuff, IDX_PARAM_NEW_SKILL_COUNT, buffInfo.m_param[0]);
		}

		uint32_t newSkillId = GetParamValue(pBuff, IDX_PARAM_NEW_SKILL_ID);

		SkillPart* pPart = dynamic_cast<SkillPart*>(pRecv->GetPart(PART_SKILL));
		if (pPart)
		{
			uint32_t oldSkillId = 0;
			uint32_t skillLevel = 0;
			std::unordered_map<uint32_t, stSkillInfo>& skillLst = pPart->GetSkillInfo();
			std::unordered_map<uint32_t, stSkillInfo>::iterator it = skillLst.begin();
			for (; it != skillLst.end(); it++)
			{
				uint32_t skillId = it->first;
				const SkillSkillCfgInfo *pInfo = g_GetSkillSkillCfgTable()->GetSkillSkillCfgInfo(skillId);
				if (pInfo && pInfo->skillType == 1) //普工技能
				{
					oldSkillId = skillId;
					skillLevel = it->second._level;
				}
			}

			SetParamValue(pBuff, IDX_PARAM_OLD_SKILL_ID, oldSkillId);
			SetParamValue(pBuff, IDX_PARAM_SKILL_LEVEL, skillLevel);
			//pPart->RemoveSkill(oldSkillId,false);
			pPart->AddSkill(newSkillId, skillLevel, 0,true,false);

			BuffReplaceNormalSkills msg;
			msg.set_cid(pRecv->GetCid());
			msg.mutable_oldskill()->set_skillid(oldSkillId);
			msg.mutable_oldskill()->set_cd(0);
			msg.mutable_oldskill()->set_skilllev(skillLevel);

			msg.mutable_newskill()->set_skillid(newSkillId);
			msg.mutable_newskill()->set_cd(0);
			msg.mutable_newskill()->set_skilllev(skillLevel);

			pRecv->BroadCastData(LOGIC_TO_CLIENT_REPLACE_NORMAL_SKILL, &msg, true);

			pRecv->AddBuffState(CREATURE_BUFF_STATE_REFIX_SKILL);
		}

		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int count = GetParamValue(pBuff, IDX_PARAM_NEW_SKILL_COUNT);
		uint32_t newSkillId = GetParamValue(pBuff, IDX_PARAM_NEW_SKILL_ID);
		if (pBuff->GetBuffBag()->GetBuffPart()->GetBuffEventParam().m_skillId == newSkillId)
		{
			count--;
		}

		SetParamValue(pBuff, IDX_PARAM_NEW_SKILL_COUNT, count);
		if (count <= 0)
		{
			pBuff->GetBuffBag()->BuffEffect_OnEffectFadeOut();
		}
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		uint32_t newSkillId = GetParamValue(pBuff, IDX_PARAM_NEW_SKILL_ID);
		uint32_t oldSkillId = GetParamValue(pBuff, IDX_PARAM_OLD_SKILL_ID);
		uint32_t skillLevel = GetParamValue(pBuff, IDX_PARAM_SKILL_LEVEL);

		SkillPart* pPart = dynamic_cast<SkillPart*>(pRecv->GetPart(PART_SKILL));
		if (pPart)
		{
			pPart->RemoveSkill(newSkillId,false);
			//pPart->AddSkill(oldSkillId, skillLevel, 0,true,false);

			BuffReplaceNormalSkills msg;
			msg.set_cid(pRecv->GetCid());
			msg.mutable_oldskill()->set_skillid(newSkillId);
			msg.mutable_oldskill()->set_cd(0);
			msg.mutable_oldskill()->set_skilllev(skillLevel);

			msg.mutable_newskill()->set_skillid(oldSkillId);
			msg.mutable_newskill()->set_cd(0);
			msg.mutable_newskill()->set_skilllev(skillLevel);

			pRecv->BroadCastData(LOGIC_TO_CLIENT_REPLACE_NORMAL_SKILL, &msg, true);
			
		}
		pRecv->RemoveBuffState(CREATURE_BUFF_STATE_REFIX_SKILL);

	}

	virtual void OnEvent_CountSkill(BuffEffectInfo* pBuff, Creature* pRecv, uint32_t skillId) const
	{

	}
};


/*
=======================================================================================================================
说明
BuffLogic_011_Teleport ;
功能描述：11-闪现（闪现的距离，毫米）
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_011_Flash : public IBuffLogic
{
public:
	enum { ID = effectTypeFlash, };
	enum BuffEffectParamIndex { IDX_FLASH_DICT = 0,};
	BuffLogic_011_Flash(){};
	~BuffLogic_011_Flash(){};

	int32_t GetParamDict(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_FLASH_DICT);
	};

	void SetParamDict(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_FLASH_DICT, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamDict(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		if (pRecv->GetScene() == nullptr)
		{
			return;
		}

		Point3<float> dir = pRecv->GetDir();
		dir.y = 0;
		if (dir.length()>=0.1)
		{
			dir = dir / dir.length();
		}

		Point3<float> srcPos = pRecv->GetPos();
		float dict = GetParamDict(pBuff) / 1000.0f;
		Point3<float> targetPos = srcPos;

		Map* pMap = g_GetMapMgr()->GetMap(pRecv->GetMapId());
		bool ret = false;
		if (pMap)
		{
			for (float d = 0; d <= dict; d += 0.1f)
			{
				Point3<float> tmpPos = srcPos + dir * d;
				Point3<float> tmpTargetPos;
				ret = pMap->FindNearestPos(tmpPos.x, tmpPos.z, tmpPos.y, &tmpTargetPos.x, &tmpTargetPos.z, &tmpTargetPos.y, nullptr);
				if (ret)
				{
					targetPos = tmpTargetPos;
				}
				else
				{
					ret = false;
					break;
				}
			}
		}

		pRecv->Teleporting(targetPos);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_012_HaloDamage ;
功能描述：12-光环持续伤害
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_012_HaloDamage : public IBuffLogic
{
public:
	enum { ID = effectTypeHaloDamage, };
	enum BuffEffectParamIndex { IDX_RADIUX = 0, IDX_DAMAGE = 1, };
	BuffLogic_012_HaloDamage(){};
	~BuffLogic_012_HaloDamage(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_DAMAGE, param);
		if (buffInfo.m_param.size() >= 2)
		{
			//这里是ms
			pBuff->SetIntervalTime(buffInfo.m_param[0]);
			SetParamValue(pBuff, IDX_RADIUX, buffInfo.m_param[1]);
		}
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		Scene* pScene = pRecv->GetScene();
		if (pScene)
		{
			Creature* pSender = pScene->GetCreature(pBuff->GetSenderId());

			std::list<uint64_t> cidList;
			float radius = GetParamValue(pBuff, IDX_RADIUX) / 1000.0f;
			int32_t value = GetParamValue(pBuff, IDX_DAMAGE);
			pScene->FindCreatureInCircle(cidList, pRecv->GetPos(), radius);

			for (auto it = cidList.begin(); it != cidList.end(); it++)
			{
				auto cid = *it;
				//未完待续，还需要考虑阵营
				if (cid == pBuff->GetSenderId())
				{
					continue;
				}

				Creature* pCreature = pScene->GetCreature(cid);
				if (pCreature && pCreature->IsDead() == false)
				{
					if (pSender && pSender->IsFriendSide(pCreature))
					{
						continue;
					}
					pCreature->AddAttr(C_HP, -1 * (int64_t)value, false, pBuff->GetSenderId());

					if (pCreature->CreatureKind() == CREATURE_MONSTER || pCreature->CreatureKind() == CREATURE_NPC)
					{
						if (pCreature->GetAiData())
						{
							pCreature->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  value);
						}
					}

					UseBuffResult::Target *pTarget = useResult.add_targets();
					pTarget->set_targetcid(pCreature->GetCid());
					pTarget->set_bedead(pCreature->IsDead());
					Attr* pAttr = pTarget->add_creatureattr();
					pAttr->set_attrnum(pCreature->GetAttrNum(C_HP));
					pAttr->set_attrvalue(pCreature->GetAttr(C_HP));

					//跳字表现数据
					DigPerfor* pdigti = pTarget->add_digperfors();
					pdigti->set_type(DigPerfor_Type_reduceHp);
					pdigti->set_value(value);

					//攻击事件触发
					skillAttackEvent  attackInfo;
					attackInfo.skillId = pBuff->GetSkillId();
					attackInfo.victim = cid;
					attackInfo.attacker = pBuff->GetSenderId();
					attackInfo.sufferedValue = value;

					//通知攻击者和受害者攻击事件
					g_GetEvent()->FireExecute(EVENT_ATTACK_SOMEBODY, pBuff->GetSenderId(), 0, (skillAttackEvent*)&attackInfo, sizeof(skillAttackEvent));
					g_GetEvent()->FireExecute(EVENT_UNDER_ATTACK, cid, 0, (skillAttackEvent*)&attackInfo, sizeof(skillAttackEvent));
				}
			}
		}

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_013_HaloBeat ;
功能描述：13-光环击退
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_013_HaloBeat : public IBuffLogic
{
public:
	enum { ID = effectTypeHaloBeat, };
	enum BuffEffectParamIndex { IDX_RADIUX = 0, IDX_BEAT_DICT = 1, };
	BuffLogic_013_HaloBeat(){};
	~BuffLogic_013_HaloBeat(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_BEAT_DICT, param);
		if (buffInfo.m_param.size() >= 2)
		{
			//这里是ms
			pBuff->SetIntervalTime(buffInfo.m_param[0]);
			SetParamValue(pBuff, IDX_RADIUX, buffInfo.m_param[1]);
		}
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		Scene* pScene = pRecv->GetScene();
		if (pScene)
		{
			Creature* pSender = pScene->GetCreature(pBuff->GetSenderId());

			std::list<uint64_t> cidList;
			float radius = GetParamValue(pBuff, IDX_RADIUX) / 1000.0f;
			float dict = GetParamValue(pBuff, IDX_BEAT_DICT) / 1000.0f;
			pScene->FindCreatureInCircle(cidList, pRecv->GetPos(), radius);

			for (auto it = cidList.begin(); it != cidList.end(); it++)
			{
				auto cid = *it;
				if (cid == pBuff->GetSenderId())
				{
					continue;
				}

				Creature* pCreature = pScene->GetCreature(cid);
				if (pCreature && pCreature->IsDead() == false)
				{
					if (pSender && pSender->IsFriendSide(pCreature))
					{
						continue;
					}

					pCreature->StopMove();

					float dirDict = point3Length(pCreature->GetPos(), pRecv->GetPos());
					Point3<float> dir = pCreature->GetPos() - pRecv->GetPos();

					if (dirDict > 0.1f)
					{
						dir = dir / dirDict;
					}
					else
					{
						dir = pCreature->GetDir();
					}

					Point3<float> targetPos = pCreature->GetPos() + dir * dict;
					pCreature->BeatBack(targetPos);

					//攻击事件触发
					skillAttackEvent  attackInfo;
					attackInfo.skillId = pBuff->GetSkillId();
					attackInfo.victim = cid;
					attackInfo.attacker = pBuff->GetSenderId();
					attackInfo.sufferedValue = 0;

					//通知攻击者和受害者攻击事件
					g_GetEvent()->FireExecute(EVENT_ATTACK_SOMEBODY, pBuff->GetSenderId(), 0, (skillAttackEvent*)&attackInfo, sizeof(skillAttackEvent));
					g_GetEvent()->FireExecute(EVENT_UNDER_ATTACK, cid, 0, (skillAttackEvent*)&attackInfo, sizeof(skillAttackEvent));
				}
			}
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_014_SummonCreature ;
功能描述：14-召唤生物
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_014_SummonCreature : public IBuffLogic
{
public:
	enum { ID = effectTypeSummonCreature, };
	enum BuffEffectParamIndex { IDX_CREATURE_ID = 0, IDX_CREATURE_COUNT = 1, };
	BuffLogic_014_SummonCreature(){};
	~BuffLogic_014_SummonCreature(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_CREATURE_ID, param);
		if (buffInfo.m_param.size() >= 1)
		{
			SetParamValue(pBuff, IDX_CREATURE_COUNT, buffInfo.m_param[0]);
		}
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->GetScene() == nullptr)
		{
			return;
		}
		
		int32_t summonId = GetParamValue(pBuff, IDX_CREATURE_ID);
		int32_t summonCount = GetParamValue(pBuff, IDX_CREATURE_COUNT);
		uint32_t sceneId = pRecv->GetScene()->GetSceneId();
		SkillPart* pSkillPart = dynamic_cast<SkillPart*>(pRecv->GetPart(PART_SKILL));
		if (pSkillPart == nullptr)
			return;

		const SkillSkillCfgInfo *pSkillInfo = g_GetSkillSkillCfgTable()->GetSkillSkillCfgInfo(pBuff->GetSkillId());
		stSkillInfo* pInfo = pSkillPart->GetSkillInfo(pBuff->GetSkillId());

		for (int i = 0; i < summonCount; i++)
		{
			Point3<float> pos;
			if (pSkillInfo)
			{
				if (pSkillInfo->summonType == 1)
				{
					int value = CommonApi::StrToInt(pSkillInfo->summonValue);
					pos = AiLogicUtility::GetRandomPosOnCircle(pRecv->GetScene()->GetMapId(), pRecv->GetPos(), value/1000.0f);
				}
				else if (pSkillInfo->summonType == 2)
				{
					if (pInfo)
					{
						int value = CommonApi::StrToInt(pSkillInfo->summonValue);
						pos = AiLogicUtility::GetRandomPosOnCircle(pRecv->GetScene()->GetMapId(), pInfo->_posSummon, value/1000.0f);
					}
				}
			}
			else
			{
				pos = pRecv->GetPos();
			}

			if ( pos == Point3<float>())
			{
				pos = pRecv->GetPos();
			}
			
			MonsterExtendInfo extend;
			extend.set_mastercid(pRecv->GetCid());
			extend.set_mastercreaturekind(pRecv->CreatureKind());
			extend.set_level(pBuff->GetSkillLevel());
			if (pRecv->CreatureKind() == CREATURE_PLAYER)
			{
				extend.set_campid(pRecv->GetAttr(C_CAMP_ID));
			}
			else if (pRecv->CreatureKind() == CREATURE_MONSTER)
			{
				Monster* pOwner = dynamic_cast<Monster*>(pRecv);
				if(pOwner)
				{
					extend.set_campid(pOwner->GetMonsterCampID());
				}
			}
			else if (pRecv->CreatureKind() == CREATURE_NPC)
			{
				Npc* pNpc = dynamic_cast<Npc*>(pRecv);
				if (pNpc)
				{
					extend.set_campid(pNpc->GetNpcInfo()->npcCamp);
				}
			}
			MonsCreateParam createParam;
			createParam.createType = EMonsCreateType_SummonBuff;
			createParam.createTypeVal = extend.mastercid();
			Monster* pMonster = g_GetCreatureMgr()->CreateMonster(summonId, sceneId, pos, createParam, pRecv->GetDir(), -1, &extend);
			if (pMonster)
			{
				pMonster->SetMonsterMasterCID(pRecv->GetCid());
				pMonster->SetMonsterMasterKind(pRecv->CreatureKind());

				if (pRecv->CreatureKind() == CREATURE_PLAYER)
				{
					pMonster->SetMonsterCampID(pRecv->GetAttr(C_CAMP_ID));
				}
				else if (pRecv->CreatureKind() == CREATURE_MONSTER)
				{
					Monster* pOwner = dynamic_cast<Monster*>(pRecv);
					if(pOwner)
					{
						pMonster->SetMonsterCampID(pOwner->GetMonsterCampID());
					}
				}
				else if (pRecv->CreatureKind() == CREATURE_NPC)
				{
					Npc* pNpc = dynamic_cast<Npc*>(pRecv);
					if (pNpc)
					{
						pMonster->SetMonsterCampID(pNpc->GetNpcInfo()->npcCamp);
					}
				}
				pRecv->AddSummon(pMonster->GetCid());
			}
		}
		
	}
};

/*
=======================================================================================================================
说明
BuffLogic_015_HaloDamageSquare ;
功能描述：15-光环持续伤害矩形
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_015_HaloDamageSquare : public IBuffLogic
{
public:
	enum { ID = effectTypeHaloDamageSquare, };
	enum BuffEffectParamIndex { IDX_HIGHT = 0, IDX_WIDTH = 1, IDX_DAMAGE = 2, };
	BuffLogic_015_HaloDamageSquare(){};
	~BuffLogic_015_HaloDamageSquare(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_DAMAGE, param);
		if (buffInfo.m_param.size() >= 3)
		{
			//这里是ms
			pBuff->SetIntervalTime(buffInfo.m_param[0]);
			SetParamValue(pBuff, IDX_HIGHT, buffInfo.m_param[1]);
			SetParamValue(pBuff, IDX_WIDTH, buffInfo.m_param[2]);
		}
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		Scene* pScene = pRecv->GetScene();
		if (pScene)
		{
			Creature* pSender = pScene->GetCreature(pBuff->GetSenderId());

			std::list<uint64_t> cidList;
			float high = GetParamValue(pBuff, IDX_HIGHT) / 1000.0f;
			float width = GetParamValue(pBuff, IDX_WIDTH) / 1000.0f;
			int32_t value = GetParamValue(pBuff, IDX_DAMAGE);
			pScene->FindCreatureInRect(cidList, pRecv->GetPos(), pRecv->GetDir(), high, width);

			for (auto it = cidList.begin(); it != cidList.end(); it++)
			{
				auto cid = *it;
				Creature* pCreature = pScene->GetCreature(cid);
				if (pCreature && pCreature->IsDead() == false)
				{
					if (pSender && pSender->IsFriendSide(pCreature))
					{
						continue;
					}

					pCreature->AddAttr(C_HP, -1 * (int64_t)value, false, pBuff->GetSenderId());
					LogInfoFmtPrint("Creature Cid: %d, intervalTime:%d, continuanceTime:%d,OnEvent_Active: value = %d",
						pCreature->GetCid(), pBuff->GetIntervalTime(), pBuff->GetContinuanceTime(), value);

					UseBuffResult::Target *pTarget = useResult.add_targets();
					pTarget->set_targetcid(pRecv->GetCid());
					pTarget->set_bedead(pRecv->IsDead());
					Attr* pAttr = pTarget->add_creatureattr();
					pAttr->set_attrnum(pRecv->GetAttrNum(C_HP));
					pAttr->set_attrvalue(value);

					//跳字表现数据
					DigPerfor* pdigti = pTarget->add_digperfors();
					pdigti->set_type(DigPerfor_Type_reduceHp);
					pdigti->set_value(value);

					//攻击事件触发
					skillAttackEvent  attackInfo;
					attackInfo.skillId = pBuff->GetSkillId();
					attackInfo.victim = cid;
					attackInfo.attacker = pBuff->GetSenderId();
					attackInfo.sufferedValue = value;

					//通知攻击者和受害者攻击事件
					g_GetEvent()->FireExecute(EVENT_ATTACK_SOMEBODY, pBuff->GetSenderId(), 0, (skillAttackEvent*)&attackInfo, sizeof(skillAttackEvent));
					g_GetEvent()->FireExecute(EVENT_UNDER_ATTACK, cid, 0, (skillAttackEvent*)&attackInfo, sizeof(skillAttackEvent));
				}
			}
		}

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_016_DisperseMark ;
功能描述：驱散mark 在buff bag 层次处理， 这里什么都不做
参数描述：无
应用举例：
备注:无
=======================================================================================================================
*/
class BuffLogic_016_DisperseBuffBagId : public IBuffLogic
{
public:
	enum { ID = effectTypeDisperseBuffBagId, };
	BuffLogic_016_DisperseBuffBagId()
	{

	}
	~BuffLogic_016_DisperseBuffBagId()
	{

	}
};

/*
=======================================================================================================================
说明
BuffLogic_017_ImmuneBuffBagId ;
功能描述：免疫（数据填写为驱散的buff类型32位掩码，持续时间）
参数描述：无
应用举例：
备注:无
=======================================================================================================================
*/
class BuffLogic_017_ImmuneBuffBagId : public IBuffLogic
{
public:
	enum { ID = effectTypeImmuneBuffBagId, };
	BuffLogic_017_ImmuneBuffBagId()
	{

	}
	~BuffLogic_017_ImmuneBuffBagId()
	{

	}
};

/*
=======================================================================================================================
说明
BuffLogic_018_OneHitKill ;
功能描述：18-一击必杀
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_018_OneHitKill : public IBuffLogic
{
public:
	enum { ID = effectTypeOneHitKill, };
	enum BuffEffectParamIndex { IDX_DAMAGE_PERCENT, };
	BuffLogic_018_OneHitKill(){};
	~BuffLogic_018_OneHitKill(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_DAMAGE_PERCENT, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int32_t percent = GetParamValue(pBuff, IDX_DAMAGE_PERCENT);
		int32_t hp = pRecv->GetAttr(C_HP);
		int32_t value = hp * percent / 10000;

		pRecv->AddAttr(C_HP, -1 * (int64_t)value, false, pBuff->GetSenderId());

		if (pRecv->CreatureKind() == CREATURE_MONSTER || pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (pRecv->GetAiData())
			{
				pRecv->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  value);
			}
		}

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_HP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_HP));

		//跳字表现数据
		DigPerfor* pdigti = pTarget->add_digperfors();
		pdigti->set_type(DigPerfor_Type_reduceHp);
		pdigti->set_value(value);

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_019_ReduceSkillCd ;
功能描述：19-减少技能冷却时间
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_019_ReduceSkillCd : public IBuffLogic
{
public:
	enum { ID = effectTypeReduceSkillCd, };
	enum BuffEffectParamIndex { IDX_PARAM, };
	BuffLogic_019_ReduceSkillCd(){};
	~BuffLogic_019_ReduceSkillCd(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{

	}
};

/*
=======================================================================================================================
说明
BuffLogic_020_SeeInVisible ;
功能描述：20-光环反隐身
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_020_SeeInVisible : public IBuffLogic
{
public:
	enum { ID = effectTypeSeeVisible, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_020_SeeInVisible(){};
	~BuffLogic_020_SeeInVisible(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		pRecv->AddBuffState(CREATURE_BUFF_STATE_SEEINVISIBLE);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CREATURE_BUFF_STATE_SEEINVISIBLE);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_021_AddHpOneTime ;
功能描述：21-一次性加血
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_021_AddHpOneTime : public IBuffLogic
{
public:
	enum { ID = effectTypeAddHpOneTime, };
	enum BuffEffectParamIndex { IDX_HP = 0, };
	BuffLogic_021_AddHpOneTime(){};
	~BuffLogic_021_AddHpOneTime(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		if (param < 0)
		{
			param = 0;
		}
		SetParamValue(pBuff, IDX_HP, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff, IDX_HP);

		//不能给怪物加血
		if (pRecv->GetScene() && value > 0)
		{
			Creature* pSender = pRecv->GetScene()->GetCreature(pBuff->GetSenderId());
			if (pSender && pSender->CreatureKind() == CREATURE_PLAYER)
			{
				if (pRecv->CreatureKind() != CREATURE_PLAYER)
				{
					if (pRecv->CreatureKind() == CREATURE_MONSTER)
					{
						Monster* pMonster = dynamic_cast<Monster*>(pRecv);
						if (pMonster->GetParentMonsterType() != PARENT_MONSTER_TYPE_SUMMON)
						{
							return;
						}
					}
					else
					{
						return;
					}
				}
			}
		}

		pRecv->AddAttr(C_HP, (int64_t)value, true, 0);

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_HP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_HP));

		//跳字表现数据
		DigPerfor* pdigti = pTarget->add_digperfors();
		pdigti->set_type(DigPerfor_Type_addHp);
		pdigti->set_value(value);

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_022_DelHpOneTime ;
功能描述：22-一次性减血
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_022_DelHpOneTime : public IBuffLogic
{
public:
	enum { ID = effectTypeDelHpOneTime, };
	enum BuffEffectParamIndex { IDX_HP = 0, };
	BuffLogic_022_DelHpOneTime(){};
	~BuffLogic_022_DelHpOneTime(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		if (param < 0)
		{
			param = 0;
		}
		SetParamValue(pBuff, IDX_HP, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff, IDX_HP);

		pRecv->AddAttr(C_HP, -1*(int64_t)value, true, 0);

		if (pRecv->CreatureKind() == CREATURE_MONSTER || pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (pRecv->GetAiData())
			{
				pRecv->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  value);
			}
		}

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_HP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_HP));

		//跳字表现数据
		DigPerfor* pdigti = pTarget->add_digperfors();
		pdigti->set_type(DigPerfor_Type_reduceHp);
		pdigti->set_value(value);

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_023_Drag ;
功能描述：23-拖拽
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_023_Drag : public IBuffLogic
{
public:
	enum { ID = effectTypeDrap, };
	enum BuffEffectParamIndex { IDX_DICT = 0, };
	BuffLogic_023_Drag(){};
	~BuffLogic_023_Drag(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		if (param < 0)
		{
			param = 0;
		}

		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		Creature* pSender = pRecv->GetScene()->GetCreature(pBuff->GetSenderId());
		if (pSender)
		{
			pRecv->Teleporting(pSender->GetPos());

			if (pRecv->CreatureKind() == CREATURE_MONSTER || pRecv->CreatureKind() == CREATURE_NPC)
			{
				if (pRecv->GetAiData())
				{
					pRecv->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  0);
				}
			}
		}
	}
};

/*
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
说明
BuffLogic_024_ExchangeHp;
功能描述：24 - 互换血量百分比
参数描述：	0个参数
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
*/
class BuffLogic_024_ExchangeHp : public IBuffLogic
{
public:
	enum { ID = effectTypeExchangeHp, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_024_ExchangeHp(){};
	~BuffLogic_024_ExchangeHp(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		if (pRecv->GetScene() == nullptr)
		{
			return;
		}

		Creature* pSender = pRecv->GetScene()->GetCreature(pBuff->GetSenderId());
		if (pSender == nullptr)
		{
			return;
		}

		int32_t senderMaxHp = pSender->GetAttr(C_MAX_HP);
		int32_t senderHp = pSender->GetAttr(C_HP);
		int32_t recverMaxHp = pRecv->GetAttr(C_MAX_HP);
		int32_t recverHp = pRecv->GetAttr(C_HP);

		int64_t newSenderHp = senderMaxHp * (float)recverHp / (float)recverMaxHp;
		int64_t newRecverHp = recverMaxHp * (float)senderHp / (float)senderMaxHp;
		pSender->AddAttr(C_HP, newSenderHp - pSender->GetAttr(C_HP), true);
		pRecv->AddAttr(C_HP, newRecverHp - pRecv->GetAttr(C_HP), true);

		if (pRecv->CreatureKind() == CREATURE_MONSTER || pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (pRecv->GetAiData())
			{
				pRecv->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  0);
			}
		}
	}

};

/*
=======================================================================================================================
说明
BuffLogic_025_NoSee ;
功能描述：25-致盲
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_025_NoSee : public IBuffLogic
{
public:
	enum { ID = effectTypeNoSee, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_025_NoSee(){};
	~BuffLogic_025_NoSee(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}


	virtual bool IsOverTimed(void) const{ return true; };
	virtual bool IsIntervaled(void) const{ return false; };

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		pRecv->AddBuffState(CREATURE_BUFF_STATE_NOSEE);

		if (pRecv->CreatureKind() == CREATURE_MONSTER || pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (pRecv->GetAiData())
			{
				pRecv->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  0);
			}
		}
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CREATURE_BUFF_STATE_NOSEE);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_027_MaBi ;
功能描述：27-麻痹
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_027_MaBi : public IBuffLogic
{
public:
	enum { ID = effectTypeMaBi, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_027_MaBi(){};
	~BuffLogic_027_MaBi(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		pRecv->AddBuffState(CREATURE_BUFF_STATE_MABI);

		if (pRecv->CreatureKind() == CREATURE_MONSTER || pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (pRecv->GetAiData())
			{
				pRecv->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  0);
			}
		}
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CREATURE_BUFF_STATE_MABI);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_028_AddGoldPercentForever ;
功能描述：28-
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_028_AddGoldPercentForever : public IBuffLogic
{
public:
	enum { ID = effectTypeAddGoldPercentForever, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_028_AddGoldPercentForever(){};
	~BuffLogic_028_AddGoldPercentForever(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

	}
};

/*
=======================================================================================================================
说明
BuffLogic_030_AddDropPercentForever ;
功能描述：30-
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_030_AddDropPercentForever : public IBuffLogic
{
public:
	enum { ID = effectTypeAddDropPercentForever, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_030_AddDropPercentForever(){};
	~BuffLogic_030_AddDropPercentForever(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

	}
};

/*
=======================================================================================================================
说明
BuffLogic_031_ZiBao;
功能描述：31-自爆
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_031_ZiBao : public IBuffLogic
{
public:
	enum { ID = effectTypeZiBao, };
	enum BuffEffectParamIndex { IDX_SELF_DAMAGE_PERCENT = 0,IDX_DAMAGE_VALUE = 1, IDX_RADIUX = 2,};
	BuffLogic_031_ZiBao(){};
	~BuffLogic_031_ZiBao(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}


	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		if (param < 0)
		{
			param = 0;
		}

		if (buffInfo.m_param.size() >= 2)
		{
			SetParamValue(pBuff, IDX_SELF_DAMAGE_PERCENT, buffInfo.m_param[0]);
			SetParamValue(pBuff, IDX_RADIUX, buffInfo.m_param[1]);
		}
		SetParamValue(pBuff, IDX_DAMAGE_VALUE, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		Scene* pScene = pRecv->GetScene();
		if (pScene)
		{
			std::list<uint64_t> cidList;
			float radius = GetParamValue(pBuff, IDX_RADIUX) / 1000.0f;

			pScene->FindCreatureInCircle(cidList, pRecv->GetPos(), radius);

			Creature* pSender = pScene->GetCreature(pBuff->GetSenderId());
			if (pSender == nullptr)
			{
				return;
			}

			UseBuffResult	useResult;
			useResult.set_skillid(pBuff->GetSkillId());
			useResult.set_usercid(pBuff->GetSenderId());
			useResult.set_buffid(pBuff->GetEffectType());
			useResult.set_buffbaginstid(0);
			useResult.set_buffbagid(0);

			for (auto it = cidList.begin(); it != cidList.end(); it++)
			{
				auto cid = *it;
				Creature* pCreature = pScene->GetCreature(cid);
				if (pCreature && !pSender->IsFriendSide(pCreature) && pCreature != pSender)
				{
					int64_t hp = GetParamValue(pBuff, IDX_DAMAGE_VALUE);
					if (hp == 0)
					{
						continue;
					}

					pCreature->AddAttr(C_HP, -hp, true);

					if (pCreature->CreatureKind() == CREATURE_MONSTER || pCreature->CreatureKind() == CREATURE_NPC)
					{
						if (pCreature->GetAiData())
						{
							pCreature->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  hp);
						}
					}

					UseBuffResult::Target *pTarget = useResult.add_targets();
					pTarget->set_targetcid(pCreature->GetCid());
					pTarget->set_bedead(pCreature->IsDead());
					Attr* pAttr = pTarget->add_creatureattr();
					pAttr->set_attrnum(pCreature->GetAttrNum(C_HP));
					pAttr->set_attrvalue(pCreature->GetAttr(C_HP));

					//跳字表现数据
					DigPerfor* pdigti = pTarget->add_digperfors();
					pdigti->set_type(DigPerfor_Type_reduceHp);
					pdigti->set_value(hp);
				}
			}

			if (pSender)
			{
				int64_t hp = pSender->GetAttr(C_HP);
				hp = hp * GetParamValue(pBuff, IDX_SELF_DAMAGE_PERCENT) / 10000.0f;
				pSender->AddAttr(C_HP, -hp, true);

				UseBuffResult::Target *pTarget = useResult.add_targets();
				pTarget->set_targetcid(pSender->GetCid());
				pTarget->set_bedead(pSender->IsDead());
				Attr* pAttr = pTarget->add_creatureattr();
				pAttr->set_attrnum(pSender->GetAttrNum(C_HP));
				pAttr->set_attrvalue(pSender->GetAttr(C_HP));

				//跳字表现数据
				DigPerfor* pdigti = pTarget->add_digperfors();
				pdigti->set_type(DigPerfor_Type_reduceHp);
				pdigti->set_value(hp);
			}

			pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_032_WuDi;
功能描述：32-无敌
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_032_WuDi : public IBuffLogic
{
public:
	enum { ID = effectTypeWuDi, };
	enum BuffEffectParamIndex { IDX_HP_Shield = 0, };
	BuffLogic_032_WuDi(){};
	~BuffLogic_032_WuDi(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		if (param < 0)
		{
			param = 0;
		}

		SetParamValue(pBuff, IDX_HP_Shield, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		pRecv->AddBuffState(CREATURE_BUFF_STATE_WUDI);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CREATURE_BUFF_STATE_WUDI);
	}

	//damage 是个负数
	virtual void OnEvent_ReduceDamage(BuffEffectInfo* pBuff, Creature* pRecv, Creature* pAttack, uint32_t skillId, int32_t &damage) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (damage <= 0)
		{
			return;
		}

		int32_t hpShield = GetParamValue(pBuff, IDX_HP_Shield);

		if (hpShield > damage)
		{
			hpShield -= damage;
			damage = 0;
		}
		else
		{
			damage -= hpShield;
			hpShield = 0;
		}

		SetParamValue(pBuff, IDX_HP_Shield, hpShield);

		if (hpShield <= 0)
		{
			pBuff->GetBuffBag()->BuffEffect_OnEffectFadeOut();
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_034_AddGoldPercent
功能描述：28-
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_034_AddGoldPercent : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_GOLD_PERCENT = 0, };
	BuffLogic_034_AddGoldPercent(){};
	~BuffLogic_034_AddGoldPercent(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_GOLD_PERCENT, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int32_t param = GetParamValue(pBuff, IDX_PARAM_GOLD_PERCENT);

		BuffPart* pBuffPart = pBuff->GetBuffBag()->GetBuffPart();
		if (pBuffPart)
		{
			pBuffPart->AddBuffDropGoldPercent(param);
		}
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t param = GetParamValue(pBuff, IDX_PARAM_GOLD_PERCENT);

		BuffPart* pBuffPart = pBuff->GetBuffBag()->GetBuffPart();
		if (pBuffPart)
		{
			pBuffPart->DelBuffDropGoldPercent(param);
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_035_AddDropPercent
功能描述：35-
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_035_AddDropPercent : public IBuffLogic
{
public:
	enum { ID = effectTypeAddDropPercent, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_035_AddDropPercent(){};
	~BuffLogic_035_AddDropPercent(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

	}
};

/*
=======================================================================================================================
说明
BuffLogic_036_AddBuffBag
功能描述：35-
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_036_AddBuffBag : public IBuffLogic
{
public:
	enum { ID = effectTypeAddBuffBag, };
	enum BuffEffectParamIndex { IDX_PARAM_SKILL_ID = 0, IDX_PARAM_SKILL_LEVEL = 1,};
	BuffLogic_036_AddBuffBag(){};
	~BuffLogic_036_AddBuffBag(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		const SkillSkillCfgInfo *pCfgInfo = g_GetSkillSkillCfgTable()->GetSkillSkillCfgInfo(param);
		if (pCfgInfo)
		{
			SetParamValue(pBuff, IDX_PARAM_SKILL_ID, param);
			SetParamValue(pBuff, IDX_PARAM_SKILL_LEVEL, pBuffBag->GetSkillLevel());
			return true;
		}

		return false;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int32_t skillId = GetParamValue(pBuff,IDX_PARAM_SKILL_ID);
		int32_t skillLevel = GetParamValue(pBuff,IDX_PARAM_SKILL_LEVEL);

		SkillPart* pSkillPart = dynamic_cast<SkillPart*>(pRecv->GetPart(PART_SKILL));
		if (pSkillPart)
		{
//			if (pBuff->GetBuffBag()->GetTargetType() == BUFF_BAG_TARGET_TYPE_SELF)
//			{
//				pSkillPart->AddStateBag((uint32_t)skillId, skillLevel, pRecv);
//			}
//			else
			{
				auto targetCid = pBuff->GetBuffBag()->GetBuffPart()->GetBuffEventParam().m_targetCid;
				Scene* pScene = pBuff->GetMaster()->GetScene();
				if (pScene)
				{
					auto pTarget = pScene->GetCreature(targetCid);
					pSkillPart->AddStateBag((uint32_t)skillId, skillLevel, pTarget);
					return;
				}
			}
		}
	}

};

/*
=======================================================================================================================
说明
BuffLogic_037_FullStatusReLive
功能描述：37-满状态复活
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_037_FullStatusReLive : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_CUR_HP = 0, IDX_PARAM_CUR_MP_PERCENT = 1 };
	BuffLogic_037_FullStatusReLive(){};
	~BuffLogic_037_FullStatusReLive(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		if (buffInfo.m_param.size() > 1)
		{
			SetParamValue(pBuff, IDX_PARAM_CUR_MP_PERCENT, buffInfo.m_param[0]);
		}

		SetParamValue(pBuff, IDX_PARAM_CUR_HP, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			int64_t hp = GetParamValue(pBuff, IDX_PARAM_CUR_HP);
			int64_t mp = hp * GetParamValue(pBuff, IDX_PARAM_CUR_MP_PERCENT) / 10000.0f;
			pRecv->SetAttr(C_HP, hp, true);
			pRecv->SetAttr(C_HP, mp, true);

			pRecv->OnRevive(0);
			return;
		}

	}

};

/*
=======================================================================================================================
说明
BuffLogic_038_NoUseSkill
功能描述：38-禁止使用技能
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_038_NoUseSkill : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_038_NoUseSkill(){};
	~BuffLogic_038_NoUseSkill(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		pRecv->AddBuffState(CreatureBuffStateIndex::CREATURE_BUFF_STATE_CANNOT_USE_SKILL);

		if (pRecv->CreatureKind() == CREATURE_MONSTER || pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (pRecv->GetAiData())
			{
				pRecv->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  0);
			}
		}
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}
		pRecv->RemoveBuffState(CreatureBuffStateIndex::CREATURE_BUFF_STATE_CANNOT_USE_SKILL);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_039_HpShieldBomb
功能描述：39-护盾爆炸
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_039_HpShieldBomb : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_HP_SHIELD_VALUE = 0, IDX_PARAM_BOMB_RADIUS_VALUE = 1, IDX_PARAM_MAX_SHIELD_VALUE = 2, IDX_PARAM_USE_COUNT = 3, };
	BuffLogic_039_HpShieldBomb(){};
	~BuffLogic_039_HpShieldBomb(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		if (buffInfo.m_param.size() >= 1)
		{
			SetParamValue(pBuff, IDX_PARAM_HP_SHIELD_VALUE, buffInfo.m_param[0]);
			SetParamValue(pBuff, IDX_PARAM_BOMB_RADIUS_VALUE, buffInfo.m_param[1]);
			SetParamValue(pBuff, IDX_PARAM_MAX_SHIELD_VALUE, buffInfo.m_param[0]);
		}
		SetParamValue(pBuff, IDX_PARAM_USE_COUNT, 0);
		pRecv->AddBuffState(CreatureBuffStateIndex::CREATURE_BUFF_STATE_HP_SHIELD);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int value = GetParamValue(pBuff, IDX_PARAM_USE_COUNT);
		value += 1;
		SetParamValue(pBuff, IDX_PARAM_USE_COUNT, value);

		if (value >= 2)
		{
			pBuff->GetBuffBag()->BuffEffect_OnEffectFadeOut();
		}
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}
		pRecv->RemoveBuffState(CreatureBuffStateIndex::CREATURE_BUFF_STATE_HP_SHIELD);
		int32_t radius = GetParamValue(pBuff, IDX_PARAM_BOMB_RADIUS_VALUE);
		int32_t damage = GetParamValue(pBuff, IDX_PARAM_MAX_SHIELD_VALUE) - GetParamValue(pBuff, IDX_PARAM_HP_SHIELD_VALUE);

		Scene* pScene = pRecv->GetScene();
		if (pScene)
		{
			UseBuffResult	useResult;
			useResult.set_skillid(pBuff->GetSkillId());
			useResult.set_usercid(pBuff->GetSenderId());
			useResult.set_buffid(pBuff->GetEffectType());
			useResult.set_buffbaginstid(0);
			useResult.set_buffbagid(0);

			std::list<CharIDType> cList;
			pScene->FindCreatureInBall(cList, pRecv->GetPos(), radius);
			for(auto it = cList.begin(); it != cList.end(); it++)
			{
				CharIDType cid = *it;
				Creature* pCreature = pScene->GetCreature(cid);
				if (pCreature && !pRecv->IsFriendSide(pCreature))
				{
					pCreature->AddAttr(C_HP, -1 * (int64_t)damage, pRecv->GetCid());

					if (pCreature->CreatureKind() == CREATURE_MONSTER || pCreature->CreatureKind() == CREATURE_NPC)
					{
						if (pCreature->GetAiData())
						{
							pCreature->GetAiData()->AddHateTarget(pBuff->GetSenderId(), 1,  damage);
						}
					}

					UseBuffResult::Target *pTarget = useResult.add_targets();
					pTarget->set_targetcid(pCreature->GetCid());
					pTarget->set_bedead(pCreature->IsDead());
					Attr* pAttr = pTarget->add_creatureattr();
					pAttr->set_attrnum(pCreature->GetAttrNum(C_HP));
					pAttr->set_attrvalue(pCreature->GetAttr(C_HP));

					//跳字表现数据
					DigPerfor* pdigti = pTarget->add_digperfors();
					pdigti->set_type(DigPerfor_Type_reduceHp);
					pdigti->set_value(damage);

				}
			}

			pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
		}
	}

	virtual void OnEvent_ReduceDamage(BuffEffectInfo* pBuff, Creature* pRecv, Creature* pAttack, uint32_t skillId, int32_t &damage) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (damage <= 0)
		{
			return;
		}

		int32_t hpShield = GetParamValue(pBuff, IDX_PARAM_HP_SHIELD_VALUE);

		if (hpShield > damage)
		{
			hpShield -= damage;
			damage = 0;
		}
		else
		{
			damage -= hpShield;
			hpShield = 0;
		}

		SetParamValue(pBuff, IDX_PARAM_HP_SHIELD_VALUE, hpShield);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_040_FullHpMp
功能描述：40-满状态回复HPMP
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_040_FullHpMp : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_CUR_HP = 0, IDX_PARAM_CUR_MP_PERCENT = 1 };
	BuffLogic_040_FullHpMp(){};
	~BuffLogic_040_FullHpMp(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		if (buffInfo.m_param.size() >= 1)
		{
			SetParamValue(pBuff, IDX_PARAM_CUR_MP_PERCENT, buffInfo.m_param[0]);
		}

		SetParamValue(pBuff, IDX_PARAM_CUR_HP, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int64_t hp = GetParamValue(pBuff, IDX_PARAM_CUR_HP);
		int64_t mp = hp * GetParamValue(pBuff, IDX_PARAM_CUR_MP_PERCENT) / 10000.0f;

		if (hp > pRecv->GetAttr(C_HP) && hp > 0)
		{
			pRecv->SetAttr(C_HP, hp, true);
		}
		pRecv->SetAttr(C_MP, mp, true);
	}
};


/*
=======================================================================================================================
说明
BuffLogic_041_MagicTriggerSkill
功能描述：41-法球触发技能
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_041_MagicTriggerSkill : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_SKILL_ID = 0, IDX_PARAM_TRIGGER_MAX_COUNT = 1,
		IDX_PARAM_TRIGGER_INTERNAL_TIME = 2, IDX_PARAM_TRIGGER_TIME = 3,
		IDX_PARAM_LAST_GRIGGER_TIME_LOW = 4, IDX_PARAM_LAST_GRIGGER_TIME_HIGH = 5, };
	BuffLogic_041_MagicTriggerSkill(){};
	~BuffLogic_041_MagicTriggerSkill(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		pBuff->SetParamSize(10);

		SetParamValue(pBuff, IDX_PARAM_SKILL_ID, param);
		if (buffInfo.m_param.size() >= 2)
		{
			SetParamValue(pBuff, IDX_PARAM_TRIGGER_MAX_COUNT,  buffInfo.m_param[0]);
			SetParamValue(pBuff, IDX_PARAM_TRIGGER_INTERNAL_TIME, buffInfo.m_param[1]);
			return true;
		}
		return false;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int32_t triggerTime = GetParamValue(pBuff, IDX_PARAM_TRIGGER_TIME);
		int32_t internalTime = GetParamValue(pBuff, IDX_PARAM_TRIGGER_INTERNAL_TIME);
		int32_t maxCount = GetParamValue(pBuff, IDX_PARAM_TRIGGER_MAX_COUNT);

		uint32_t lastTriggerTimeLow = GetParamValue(pBuff, IDX_PARAM_LAST_GRIGGER_TIME_LOW);
		uint32_t lastTriggerTimeHigh = GetParamValue(pBuff, IDX_PARAM_LAST_GRIGGER_TIME_HIGH);

		uint64_t lastTriggerTime = (uint64_t)lastTriggerTimeLow + (((uint64_t)lastTriggerTimeHigh) << 32);

		if (lastTriggerTime + (uint64_t)internalTime <  (uint64_t)Time::Now().UnixMSec())
		{
			triggerTime = 1;
		}
		else
		{
			triggerTime++;
		}

		if (triggerTime >= maxCount)
		{
			SetParamValue(pBuff, IDX_PARAM_TRIGGER_TIME, 0);
			SetParamValue(pBuff, IDX_PARAM_LAST_GRIGGER_TIME_LOW, 0);
			SetParamValue(pBuff, IDX_PARAM_LAST_GRIGGER_TIME_HIGH, 0);
		}
		else
		{
			lastTriggerTime = Time::Now().UnixMSec();
			lastTriggerTimeLow = lastTriggerTime;
			lastTriggerTimeHigh = lastTriggerTime >> 32;

			SetParamValue(pBuff, IDX_PARAM_TRIGGER_TIME, triggerTime);
			SetParamValue(pBuff, IDX_PARAM_LAST_GRIGGER_TIME_LOW, (int32_t)lastTriggerTimeLow);
			SetParamValue(pBuff, IDX_PARAM_LAST_GRIGGER_TIME_HIGH, (int32_t)lastTriggerTimeHigh);

			pBuff->GetBuffBag()->m_lastCdTime = 0;
			return;
		}

		uint32_t skillId = GetParamValue(pBuff, IDX_PARAM_SKILL_ID);

		NotifyUseMagicBallSkill notify;
		notify.set_charid(pRecv->GetCid());
		notify.set_skillid(skillId);
		pRecv->BroadCastData(LOGIC_TO_CLIENT_USE_MAGIC_BALL_SKILL,&notify, true);

		//添加进玩家身上
		Player * pPlayer = dynamic_cast<Player*>(pRecv);
		if (pPlayer)
		{
			SkillPart * pPart = dynamic_cast<SkillPart*>(pPlayer->GetPart(PART_SKILL));
			if (pPart && pPart->GetSkillInfo(skillId) == nullptr)
			{
				pPart->AddSkill(skillId, pBuff->GetBuffBag()->GetSkillLevel(), 0, 0, false, false);
			}
		}
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		uint32_t skillId = GetParamValue(pBuff, IDX_PARAM_SKILL_ID);

		//添加进玩家身上
		Player * pPlayer = dynamic_cast<Player*>(pRecv);
		if (pPlayer)
		{
			SkillPart * pPart = dynamic_cast<SkillPart*>(pPlayer->GetPart(PART_SKILL));
			if (pPart)
			{
				pPart->RemoveSkill(skillId,false);
			}
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_043_AddHp
功能描述：43-光环持续加血
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_043_AddHp : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_RADIUS_VALUE = 0, IDX_PARAM_ADD_HP_VALUE = 1, };
	BuffLogic_043_AddHp(){};
	~BuffLogic_043_AddHp(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_ADD_HP_VALUE, param);
		if (buffInfo.m_param.size() >= 2)
		{
			//这里是ms
			pBuff->SetIntervalTime(buffInfo.m_param[0]);
			SetParamValue(pBuff, IDX_PARAM_RADIUS_VALUE, buffInfo.m_param[1]);
		}
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		Scene* pScene = pRecv->GetScene();
		if (pScene == nullptr)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff, IDX_PARAM_ADD_HP_VALUE);
		float radius = GetParamValue(pBuff, IDX_PARAM_RADIUS_VALUE) / 1000.0f;
		float radiusSquare = radius * radius;

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		std::vector<CharIDType> vec = pRecv->GetSeeLst();
		for(auto iter = vec.begin(); iter != vec.end(); iter++)
		{
			CharIDType cid = *iter;
			Creature* pTarget = pScene->GetCreature(cid);
			if (pTarget && !pTarget->IsDead() && pRecv->IsFriendSide(pTarget) && pTarget != pRecv)
			{
				//不能给怪物加血
				if (value > 0 && pRecv->CreatureKind() == CREATURE_PLAYER)
				{
					if (pTarget->CreatureKind() != CREATURE_PLAYER)
					{
						if (pTarget->CreatureKind() == CREATURE_MONSTER)
						{
							Monster* pMonster = dynamic_cast<Monster*>(pTarget);
							if (pMonster->GetParentMonsterType() != PARENT_MONSTER_TYPE_SUMMON)
							{
								continue;
							}
						}
						else
						{
							continue;
						}
					}
				}

				float dict = point2LengthSquare(pTarget->GetPos(), pRecv->GetPos());
				if (dict < radiusSquare)
				{
					if (pTarget->GetAttr(C_HP) >= pTarget->GetAttr(C_MAX_HP))
					{
						continue;
					}

					pTarget->AddAttr(C_HP, (int64_t)value, false, pBuff->GetSenderId());
					UseBuffResult::Target *pResult = useResult.add_targets();
					pResult->set_targetcid(pTarget->GetCid());
					pResult->set_bedead(pTarget->IsDead());
					Attr* pAttr = pResult->add_creatureattr();
					pAttr->set_attrnum(pTarget->GetAttrNum(C_HP));
					pAttr->set_attrvalue(pTarget->GetAttr(C_HP));
					//跳字表现数据
					DigPerfor* pdigti = pResult->add_digperfors();
					pdigti->set_type(DigPerfor_Type_addHp);
					pdigti->set_value(value);
				}
			}
		}

		if (pRecv->GetAttr(C_HP) < pRecv->GetAttr(C_MAX_HP))
		{
			pRecv->AddAttr(C_HP, (int64_t)value, false, pBuff->GetSenderId());
			UseBuffResult::Target *pResult = useResult.add_targets();
			pResult->set_targetcid(pRecv->GetCid());
			pResult->set_bedead(pRecv->IsDead());
			Attr* pAttr = pResult->add_creatureattr();
			pAttr->set_attrnum(pRecv->GetAttrNum(C_HP));
			pAttr->set_attrvalue(pRecv->GetAttr(C_HP));
			//跳字表现数据
			DigPerfor* pdigti = pResult->add_digperfors();
			pdigti->set_type(DigPerfor_Type_addHp);
			pdigti->set_value(value);
		}

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_45_ChangeAttr ;
功能描述：45-改变attr固定值（具体的值，持续时间，skilllevel*a+b）
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_45_ChangeAttr : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_ATTR_ID = 0, IDX_PARAM_ATTR_VALUE = 1, };
	BuffLogic_45_ChangeAttr(){};
	~BuffLogic_45_ChangeAttr(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_ATTR_VALUE, param);
		if (buffInfo.m_param.size() > 0)
		{
			SetParamValue(pBuff, IDX_PARAM_ATTR_ID, buffInfo.m_param[0]);
			return true;
		}
		return false;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int32_t attr = GetParamValue(pBuff, IDX_PARAM_ATTR_ID);
		int32_t value = GetParamValue(pBuff, IDX_PARAM_ATTR_VALUE);
		uint32_t buffAttr = g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(), attr);

		pRecv->AddAttr(buffAttr, (int64_t)value, true, pBuff->GetSenderId());
		
		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());

		//if (pRecv->GetAttrNum(attr) == P_HP)
		{
			Attr* pAttr = pTarget->add_creatureattr();
			pAttr->set_attrnum(pRecv->GetAttrNum(attr));
			pAttr->set_attrvalue(pRecv->GetAttr(attr));
		}
	
		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t attr = GetParamValue(pBuff, IDX_PARAM_ATTR_ID);
		int32_t value = GetParamValue(pBuff, IDX_PARAM_ATTR_VALUE);
		uint32_t buffAttr = g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),attr);

		pRecv->AddAttr(buffAttr, -1 * (int64_t)value, true, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());

		//if (pRecv->GetAttrNum(attr) == P_HP)
		{
			Attr* pAttr = pTarget->add_creatureattr();
			pAttr->set_attrnum(pRecv->GetAttrNum(attr));
			pAttr->set_attrvalue(pRecv->GetAttr(attr));
		}

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_47_ChangeAttrPercent ;
功能描述：47-改变attr percent（具体的值，持续时间，skilllevel*a+b）
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_47_ChangeAttrPercent : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_ATTR_ID = 0, IDX_PARAM_ATTR_PERCENT_VALUE = 1, IDX_PARAM_VALUE = 2};
	BuffLogic_47_ChangeAttrPercent(){};
	~BuffLogic_47_ChangeAttrPercent(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_ATTR_PERCENT_VALUE, param);
		if (buffInfo.m_param.size() > 0)
		{
			SetParamValue(pBuff, IDX_PARAM_ATTR_ID, buffInfo.m_param[0]);
			return true;
		}
		return false;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int32_t attr = GetParamValue(pBuff, IDX_PARAM_ATTR_ID);
		int32_t percent = GetParamValue(pBuff, IDX_PARAM_ATTR_PERCENT_VALUE);
		uint32_t buffAttr = g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),attr);
		int32_t value = percent / 10000.0f * pRecv->GetAttr(attr);

		SetParamValue(pBuff, IDX_PARAM_VALUE, value);

		pRecv->AddAttr(buffAttr, (int64_t)value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();

		pAttr->set_attrnum(pRecv->GetAttrNum(attr));
		pAttr->set_attrvalue(pRecv->GetAttr(attr));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t attr = GetParamValue(pBuff, IDX_PARAM_ATTR_ID);
		uint32_t buffAttr = g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),attr);
		int32_t value = GetParamValue(pBuff, IDX_PARAM_VALUE);

		pRecv->AddAttr(buffAttr, -1 * (int64_t)value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(attr));
		pAttr->set_attrvalue(pRecv->GetAttr(attr));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_101_ChangeAP ;
功能描述：101-改变物理攻击固定值（具体的值，持续时间，skilllevel*a+b）
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_101_ChangeAP : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeAP, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_101_ChangeAP(){};
	~BuffLogic_101_ChangeAP(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_AP), (int64_t)value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();

		pAttr->set_attrnum(pRecv->GetAttrNum(C_AP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_AP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_AP), -1 * (int64_t)value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_AP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_AP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
class BuffLogic_102_ChangeAPPercent
功能描述：改变物理攻击百分比（具体的值，持续时间，skilllevel*a+b）
参数描述：	1个参数
=======================================================================================================================
*/
class BuffLogic_102_ChangeAPPercent : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeAPPercent, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_102_ChangeAPPercent(){};
	~BuffLogic_102_ChangeAPPercent(){};

	virtual bool IsOverTimed(void) const{ return true; };
	virtual bool IsIntervaled(void) const{ return false; };

	int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_APRATE), value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_AP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_AP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_APRATE), -1 * (int64_t)value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_AP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_AP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_103_ChangeMAT ;
功能描述：103-改变魔法攻击固定值（具体的值，持续时间，skilllevel*a+b）
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_103_ChangeMAT : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeMat, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_103_ChangeMAT(){};
	~BuffLogic_103_ChangeMAT(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MP), (int64_t)value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MAT));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MAT));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MP), -1 * (int64_t)value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MAT));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MAT));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
class BuffLogic_104_ChangeMatPercent
功能描述：改变魔法攻击百分比（具体的值，持续时间，skilllevel*a+b）
参数描述：	1个参数
=======================================================================================================================
*/
class BuffLogic_104_ChangeMatPercent : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeMatPercent, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_104_ChangeMatPercent(){};
	~BuffLogic_104_ChangeMatPercent(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MATRATE), (int64_t)value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MAT));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MAT));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MATRATE), -1 * (int64_t)value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MAT));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MAT));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_105_ChangeDP ;
功能描述：105-改变物理防御固定值
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_105_ChangeDP : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeDP, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_105_ChangeDP(){};
	~BuffLogic_105_ChangeDP(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_DP), value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_DP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_DP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_DP), -value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_DP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_DP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
class BuffLogic_106_ChangeMatPercent
功能描述：改变物理防御百分比（具体的值，持续时间，skilllevel*a+b）
参数描述：	1个参数
=======================================================================================================================
*/
class BuffLogic_106_ChangeDPPercent : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeDPPercent, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_106_ChangeDPPercent(){};
	~BuffLogic_106_ChangeDPPercent(){};

	virtual bool IsOverTimed(void) const{ return true; };
	virtual bool IsIntervaled(void) const{ return false; };

	int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_DPRATE), value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_DP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_DP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_DPRATE), -value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_DP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_DP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};


/*
=======================================================================================================================
说明
BuffLogic_107_ChangeMDP ;
功能描述：103-改变魔法防御固定值（具体的值，持续时间，skilllevel*a+b）
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_107_ChangeMDP : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeMDP, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_107_ChangeMDP(){};
	~BuffLogic_107_ChangeMDP(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MDP), value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MDP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MDP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MDP), -value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MDP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MDP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
class BuffLogic_108_ChangeMDPPercent
功能描述：改变魔法防御百分比（具体的值，持续时间，skilllevel*a+b）
参数描述：	1个参数
=======================================================================================================================
*/
class BuffLogic_108_ChangeMDPPercent : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeMDPPercent, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_108_ChangeMDPPercent(){};
	~BuffLogic_108_ChangeMDPPercent(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MDPRATE), value, true, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MDP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MDP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MDPRATE), -value, true, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MDP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MDP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};


/*
=======================================================================================================================
说明
BuffLogic_109_ChangeMaxHp ;
功能描述：109-改变最大生命值固定值（具体的值，持续时间，skilllevel*a+b）
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_109_ChangeMaxHp : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeMaxHp, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_109_ChangeMaxHp(){};
	~BuffLogic_109_ChangeMaxHp(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MAX_HP), value, true, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MAX_HP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MAX_HP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MAX_HP), -value, true, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MAX_HP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MAX_HP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
class BuffLogic_110_ChangeMaxHpPercent
功能描述：110-改变最大生命值百分比
参数描述：	1个参数
=======================================================================================================================
*/
class BuffLogic_110_ChangeMaxHpPercent : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeMaxHpPercent, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_110_ChangeMaxHpPercent(){};
	~BuffLogic_110_ChangeMaxHpPercent(){};

	virtual bool IsOverTimed(void) const{ return true; };
	virtual bool IsIntervaled(void) const{ return false; };

	int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MAXHPRATE), value, true, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MAX_HP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MAX_HP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MAXHPRATE), -value, true, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MAX_HP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MAX_HP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};


/*
=======================================================================================================================
说明
BuffLogic_111_ChangeMaxMp ;
功能描述：111-改变最大魔法值固定值
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_111_ChangeMaxMp : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeMaxMP, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_111_ChangeMaxMp(){};
	~BuffLogic_111_ChangeMaxMp(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MAX_MP), value, true, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MAX_MP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MAX_MP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MAX_MP), -value, true, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MAX_MP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MAX_MP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
class BuffLogic_112_ChangeMaxMPPercent
功能描述：112-改变最大魔法值百分比
参数描述：	1个参数
=======================================================================================================================
*/
class BuffLogic_112_ChangeMaxMPPercent : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeMaxMPPercent, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_112_ChangeMaxMPPercent(){};
	~BuffLogic_112_ChangeMaxMPPercent(){};

	virtual bool IsOverTimed(void) const{ return true; };
	virtual bool IsIntervaled(void) const{ return false; };

	int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MAXMPRATE), value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MAX_MP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MAX_MP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MAXMPRATE), -value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_MAX_MP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_MAX_MP));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};


/*
=======================================================================================================================
说明
BuffLogic_113_ADDHP ;
功能描述：113-加血（具体的值，持续时间，间隔时间
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_113_ADDHP : public IBuffLogic
{
public:
	enum { ID = effectTypeAddHp, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_113_ADDHP(){};
	~BuffLogic_113_ADDHP(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		if (buffInfo.m_param.size() > 0)
		{
			//这里是ms
			pBuff->SetIntervalTime(buffInfo.m_param[0]);
		}
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		//不能给怪物加血
		if (pRecv->GetScene() && value > 0)
		{
			Creature* pSender = pRecv->GetScene()->GetCreature(pBuff->GetSenderId());
			if (pSender && pSender->CreatureKind() == CREATURE_PLAYER)
			{
				if (pRecv->CreatureKind() != CREATURE_PLAYER)
				{
					if (pRecv->CreatureKind() == CREATURE_MONSTER)
					{
						Monster* pMonster = dynamic_cast<Monster*>(pRecv);
						if (pMonster->GetParentMonsterType() != PARENT_MONSTER_TYPE_SUMMON)
						{
							return;
						}
					}
					else
					{
						return;
					}
				}
			}
		}

		pRecv->AddAttr(C_HP, (int64_t)value, true, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_HP));
		pAttr->set_attrvalue(pRecv->GetAttr(C_HP));

		//跳字表现数据
		DigPerfor* pdigti = pTarget->add_digperfors();
		pdigti->set_type(DigPerfor_Type_addHp);
		pdigti->set_value(value);

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_114_ADDMP ;
功能描述：114-加蓝（具体的值，持续时间，间隔时间
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_114_ADDMP : public IBuffLogic
{
public:
	enum { ID = effectTypeAddMp, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_114_ADDMP(){};
	~BuffLogic_114_ADDMP(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		if (buffInfo.m_param.size() > 0)
		{
			//这里是ms
			pBuff->SetIntervalTime(buffInfo.m_param[0]);
		}
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		//不能给怪物加血
		if (pRecv->GetScene() && value > 0)
		{
			Creature* pSender = pRecv->GetScene()->GetCreature(pBuff->GetSenderId());
			if (pSender && pSender->CreatureKind() == CREATURE_PLAYER)
			{
				if (pRecv->CreatureKind() != CREATURE_PLAYER)
				{
					if (pRecv->CreatureKind() == CREATURE_MONSTER)
					{
						Monster* pMonster = dynamic_cast<Monster*>(pRecv);
						if (pMonster->GetParentMonsterType() != PARENT_MONSTER_TYPE_SUMMON)
						{
							return;
						}
					}
					else
					{
						return;
					}
				}
			}
		}

		pRecv->AddAttr(C_MP, (int64_t)value, true, pBuff->GetSenderId());
	}
};

/*
=======================================================================================================================
说明
BuffLogic_115_ChangeHIT ;
功能描述：115-改变命中固定值（具体的值，持续时间，skilllevel*a+b
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_115_ChangeHIT : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeHit, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_115_ChangeHIT(){};
	~BuffLogic_115_ChangeHIT(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual bool IsOverTimed(void) const{ return true; };
	virtual bool IsIntervaled(void) const{ return false; };

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_PHYHIT), value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_PHYHIT));
		pAttr->set_attrvalue(pRecv->GetAttr(C_PHYHIT));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_PHYHIT), -value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_PHYHIT));
		pAttr->set_attrvalue(pRecv->GetAttr(C_PHYHIT));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_116_ChangeDodge ;
功能描述：116-改变闪避固定值（具体的值，持续时间，skilllevel*a+b）
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_116_ChangeDodge : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeDodge, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_116_ChangeDodge(){};
	~BuffLogic_116_ChangeDodge(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);
		
		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_PHYDODGE), value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_PHYDODGE));
		pAttr->set_attrvalue(pRecv->GetAttr(C_PHYDODGE));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_PHYDODGE), -value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_PHYDODGE));
		pAttr->set_attrvalue(pRecv->GetAttr(C_PHYDODGE));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_117_ChangeCrit ;
功能描述：117-改变暴击固定值（具体的值，持续时间，skilllevel*a+b）
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_117_ChangeCrit : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeCrit, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_117_ChangeCrit(){};
	~BuffLogic_117_ChangeCrit(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual bool IsOverTimed(void) const{ return true; };
	virtual bool IsIntervaled(void) const{ return false; };

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);
		
		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_PHYCRIT), value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_PHYCRIT));
		pAttr->set_attrvalue(pRecv->GetAttr(C_PHYCRIT));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_PHYCRIT), -value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_PHYCRIT));
		pAttr->set_attrvalue(pRecv->GetAttr(C_PHYCRIT));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_118_ChangeToughNess ;
功能描述：118-改变韧性固定值（具体的值，持续时间，skilllevel*a+b
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_118_ChangeToughNess : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeToughNess, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_118_ChangeToughNess(){};
	~BuffLogic_118_ChangeToughNess(){};

	virtual int32_t GetParamValue(BuffEffectInfo* pBuff) const
	{
		return pBuff->GetParamByIndex(BuffEffectParamIndex::IDX_PARAM);
	};

	virtual void SetParamValue(BuffEffectInfo* pBuff, int32_t value) const
	{
		pBuff->SetParamByIndex(BuffEffectParamIndex::IDX_PARAM, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, param);
		return true;
	}

	virtual bool IsOverTimed(void) const{ return true; };
	virtual bool IsIntervaled(void) const{ return false; };

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_PHYTOUGHNESS), value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_PHYTOUGHNESS));
		pAttr->set_attrvalue(pRecv->GetAttr(C_PHYTOUGHNESS));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_PHYTOUGHNESS), -value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_PHYTOUGHNESS));
		pAttr->set_attrvalue(pRecv->GetAttr(C_PHYTOUGHNESS));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_119_ChangeMovePercent
119-改变移动速度百分比（具体的值，持续时间，skilllevel*a+b）
参数描述：	1个参数
=======================================================================================================================
*/
class BuffLogic_119_ChangeMovePercent : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeMovePercent, };
	enum BuffEffectParamIndex
	{
		IDX_PARAM_MOVE_PERCENT = 0,
		IDX_PARAM_CHANGE_MOVE_SPEED = 1,
	};
	BuffLogic_119_ChangeMovePercent() { }
	~BuffLogic_119_ChangeMovePercent() { }
public:
	virtual bool IsOverTimed(void) const{ return true; };
	virtual bool IsIntervaled(void) const{ return false; };

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_MOVE_PERCENT, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = pRecv->GetSpeed() * 1000 * GetParamValue(pBuff, IDX_PARAM_MOVE_PERCENT) / 10000.0f;

		SetParamValue(pBuff, IDX_PARAM_CHANGE_MOVE_SPEED, value);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MSPEED), value, true);

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff, IDX_PARAM_CHANGE_MOVE_SPEED);

		//pRecv->SetSpeed(pRecv->GetSpeed() - value/1000.0f,true);
		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_MSPEED), -value, true);

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_120_ChangeAttackPercent
120-改变攻击速度速度百分比（具体的值，持续时间，skilllevel*a+b）
参数描述：	1个参数
=======================================================================================================================
*/
class BuffLogic_120_ChangeAttackPercent : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeAttackPercent, };
	enum BuffEffectParamIndex
	{
		IDX_PARAM_ATTACK_PERCENT = 0,
		IDX_PARAM_CHANGE_ATTACK_SPEED = 1,
	};
	BuffLogic_120_ChangeAttackPercent() { }
	~BuffLogic_120_ChangeAttackPercent() { }
public:
	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_ATTACK_PERCENT,param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = pRecv->GetAttr(C_ASPEED) * GetParamValue(pBuff, IDX_PARAM_ATTACK_PERCENT) / 10000.0f;

		SetParamValue(pBuff, IDX_PARAM_CHANGE_ATTACK_SPEED, value);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_ASPEED), value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_ASPEED));
		pAttr->set_attrvalue(pRecv->GetAttr(C_ASPEED));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff, IDX_PARAM_CHANGE_ATTACK_SPEED);

		pRecv->AddAttr(g_GetAttrMgr()->GetBuffCNumAttr(pRecv->CreatureKind(),C_ASPEED), -value, false, pBuff->GetSenderId());

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());
		Attr* pAttr = pTarget->add_creatureattr();
		pAttr->set_attrnum(pRecv->GetAttrNum(C_ASPEED));
		pAttr->set_attrvalue(pRecv->GetAttr(C_ASPEED));

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_121_ChangeCollectPercent
121-改变采集速度百分比（具体的值，持续时间，skilllevel*a+b）
参数描述：	1个参数
=======================================================================================================================
*/
class BuffLogic_121_ChangeCollectPercent : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeCollectPercent, };
	enum BuffEffectParamIndex
	{
		IDX_PARAM = 0,
	};
	BuffLogic_121_ChangeCollectPercent() { }
	~BuffLogic_121_ChangeCollectPercent() { }
public:
	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM,param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff, IDX_PARAM);

		CollectPart* pPart = dynamic_cast<CollectPart*>(pRecv->GetPart(PART_COLLECT));
		if (pPart)
		{
			pPart->AddCollectSpeed(value);
		}

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->CreatureKind() != CREATURE_PLAYER && pRecv->IsDead())
		{
			return;
		}

		int32_t value = GetParamValue(pBuff, IDX_PARAM);

		CollectPart* pPart = dynamic_cast<CollectPart*>(pRecv->GetPart(PART_COLLECT));
		if (pPart)
		{
			pPart->DecCollectSpeed(value);
		}

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};


/*
=======================================================================================================================
说明
BuffLogic_122_ChangeExtraDamage
122-/改变额外伤害（具体的值，持续时间，skilllevel*a+b）
参数描述：	1个参数
=======================================================================================================================
*/
class BuffLogic_122_ChangeExtraDamage : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeExtraDamage, };
	enum BuffEffectParamIndex
	{
		IDX_PARAM_EXTRA_DAMAGE = 0,
	};
	BuffLogic_122_ChangeExtraDamage() { }
	~BuffLogic_122_ChangeExtraDamage() { }
public:
	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_EXTRA_DAMAGE,param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->AddBuffState(CREATURE_BUFF_STATE_ADD_EXTRA_DAMAGE);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CREATURE_BUFF_STATE_ADD_EXTRA_DAMAGE);
	}

	virtual void OnEvent_AddExtraDamage(BuffEffectInfo* pBuff, Creature* pRecv, Creature* pBeAttacked, uint32_t skillId, int32_t &damage) const
	{
		if (pRecv && pRecv->CreatureKind() == CREATURE_PLAYER && pBeAttacked && pBeAttacked->CreatureKind() == CREATURE_PLAYER)
		{
			if (pRecv->GetAttr(C_CAMP_ID) != pBeAttacked->GetAttr(C_CAMP_ID))
			{
				//计算概率，如果失败，丢弃
				uint32_t rate = Random(0, 10000);
				if (rate > (uint32_t)pBuff->GetBuffBag()->GetEffectCfgInfo()->m_pCfgInfo->startProbability)
				{
					return;
				}

				int32_t value = GetParamValue(pBuff, IDX_PARAM_EXTRA_DAMAGE);

				damage += value;
			}
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_123_ChangeReduceDamage
123-改变额外免伤（具体的值，持续时间，skilllevel*a+b）
参数描述：	1个参数
=======================================================================================================================
*/
class BuffLogic_123_ChangeReduceDamage : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeReduceDamage, };
	enum BuffEffectParamIndex
	{
		IDX_PARAM_REDUCE_DAMAGE = 0,
	};
	BuffLogic_123_ChangeReduceDamage() { }
	~BuffLogic_123_ChangeReduceDamage() { }
public:
	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_REDUCE_DAMAGE,param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->AddBuffState(CREATURE_BUFF_STATE_REDUCE_EXTRA_DAMAGE);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CREATURE_BUFF_STATE_REDUCE_EXTRA_DAMAGE);
	}

	virtual void OnEvent_ReduceDamage(BuffEffectInfo* pBuff, Creature* pRecv, Creature* pAttack, uint32_t skillId, int32_t &damage) const
	{
		//
		if (pRecv && pRecv->CreatureKind() == CREATURE_PLAYER && pAttack && pAttack->CreatureKind() == CREATURE_PLAYER)
		{
			if (pRecv->GetAttr(C_CAMP_ID) != pAttack->GetAttr(C_CAMP_ID))
			{
				//计算概率，如果失败，丢弃
				uint32_t rate = Random(0, 10000);
				if (rate > (uint32_t)pBuff->GetBuffBag()->GetEffectCfgInfo()->m_pCfgInfo->startProbability)
				{
					return;
				}

				int32_t value = GetParamValue(pBuff, IDX_PARAM_REDUCE_DAMAGE);

				if (damage > value)
				{
					damage -= value;
				}
				else
				{
					damage = 0;
				}
			}
		}
	}

};

/*
=======================================================================================================================
说明
BuffLogic_124_ChangeCollectCreatureRate
121-提升采集资源伴生物出现的概率（具体的值，持续时间，skilllevel*a+b）
参数描述：	1个参数
=======================================================================================================================
*/
class BuffLogic_124_ChangeCollectCreatureRate : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeCollectCreatureRate, };
	enum BuffEffectParamIndex
	{
		IDX_PARAM = 0,
	};
	BuffLogic_124_ChangeCollectCreatureRate() { }
	~BuffLogic_124_ChangeCollectCreatureRate() { }
public:
	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM,param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff, IDX_PARAM);

		DeputyPart* pPart = dynamic_cast<DeputyPart*>(pRecv->GetPart(PART_DEPUTY));
		if (pPart)
		{
			pPart->AddResRate(value);
		}

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		int32_t value = GetParamValue(pBuff, IDX_PARAM);

		DeputyPart* pPart = dynamic_cast<DeputyPart*>(pRecv->GetPart(PART_DEPUTY));
		if (pPart)
		{
			pPart->DecResRate(value);
		}

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_125_ChangeCollectDouble
125-采集资源双倍获取（具体的值，持续时间，skilllevel*a+b）
参数描述：	1个参数
=======================================================================================================================
*/
class BuffLogic_125_ChangeCollectDouble : public IBuffLogic
{
public:
	enum { ID = effectTypeChangeCollectDouble, };
	enum BuffEffectParamIndex
	{
		IDX_PARAM = 0,
	};
	BuffLogic_125_ChangeCollectDouble() { }
	~BuffLogic_125_ChangeCollectDouble() { }
public:
	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, value);
	};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}


		DeputyPart* pPart = dynamic_cast<DeputyPart*>(pRecv->GetPart(PART_DEPUTY));
		if (pPart)
		{
			pPart->SetDouble(true);
		}

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		DeputyPart* pPart = dynamic_cast<DeputyPart*>(pRecv->GetPart(PART_DEPUTY));
		if (pPart)
		{
			pPart->SetDouble(false);
		}

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		UseBuffResult::Target *pTarget = useResult.add_targets();
		pTarget->set_targetcid(pRecv->GetCid());
		pTarget->set_bedead(pRecv->IsDead());

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_44_ChangeBody
功能描述：44-变身
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_44_ChangeBody : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_CHANGE_BODY_ID = 0, };
	BuffLogic_44_ChangeBody(){};
	~BuffLogic_44_ChangeBody(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_CHANGE_BODY_ID, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		NotifyChangeBody body;
		body.set_charid(pRecv->GetCid());
		body.set_change_body_id(GetParamValue(pBuff, IDX_PARAM_CHANGE_BODY_ID));
		pRecv->BroadCastData(LOGIC_TO_CLIENT_START_CHANGE_BODY, &body, true);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		NotifyChangeBody body;
		body.set_charid(pRecv->GetCid());
		body.set_change_body_id(GetParamValue(pBuff, IDX_PARAM_CHANGE_BODY_ID));
		pRecv->BroadCastData(LOGIC_TO_CLIENT_END_CHANGE_BODY, &body, true);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_048_ReplaceSkill ;
功能描述：48
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_048_ReplaceSkill : public IBuffLogic
{
public:
	BuffLogic_048_ReplaceSkill(){};
	~BuffLogic_048_ReplaceSkill(){};

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		if (buffInfo.m_param.size() > 0)
		{
			pBuff->SetParam(buffInfo.m_param);
			return true;
		}
		return false;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		SkillPart* pPart = dynamic_cast<SkillPart*>(pRecv->GetPart(PART_SKILL));
		if (pPart == nullptr)
		{
			return;
		}

		auto& vecSkill = pBuff->GetParam();

		BuffReplaceAllSkills msg;
		for(int i = 0; i < (int)vecSkill.size(); i++)
		{
			uint32_t newSkillId = vecSkill[i];

			pPart->AddSkill(newSkillId, 1, 0, 0, true,false, enSkillSaveType_Online);

			::ProtoBuf::SkillCell* pCell = msg.add_newskill();
			pCell->set_skillid(newSkillId);
			pCell->set_cd(0);
			pCell->set_skilllev(1);
		}

		pRecv->SendDataToClient(LOGIC_TO_CLIENT_REPLACE_ALL_SKILL, &msg);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		SkillPart* pPart = dynamic_cast<SkillPart*>(pRecv->GetPart(PART_SKILL));
		if (pPart == nullptr)
		{
			return;
		}

		auto& vecSkill = pBuff->GetParam();

		BuffReplaceAllSkills msg;

		for(int i = 0; i < (int)vecSkill.size(); i++)
		{
			uint32_t newSkillId = vecSkill[i];

			pPart->RemoveSkill(newSkillId, false);
		}

		auto& mapSkills =  pPart->GetSkillInfo();

		for(auto iter = mapSkills.begin(); iter != mapSkills.end(); iter++)
		{
			stSkillInfo& skillInfo = iter->second;

			::ProtoBuf::SkillCell* pCell = msg.add_newskill();

			pCell->set_skillid(skillInfo._Id);
			pCell->set_cd(0);
			pCell->set_skilllev(skillInfo._level);
		}

		pRecv->SendDataToClient(LOGIC_TO_CLIENT_REPLACE_ALL_SKILL, &msg);
	}
};


/*
=======================================================================================================================
说明
BuffLogic_500_UseSpecialEffect
功能描述：35-
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_500_UseSpecialEffect : public IBuffLogic
{
public:
	enum { ID = effectTypeUseSpecialEffect, };
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_500_UseSpecialEffect(){};
	~BuffLogic_500_UseSpecialEffect(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

	}
};


/*
=======================================================================================================================
说明
BuffLogic_049_CircleHaleEffect ;
功能描述：49
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_049_CircleHaleEffect : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_RADIUS = 0, IDX_PARAM_SKILL_ID = 1, };
	BuffLogic_049_CircleHaleEffect(){};
	~BuffLogic_049_CircleHaleEffect(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_SKILL_ID, param);

		if (buffInfo.m_param.size() >= 2)
		{
			SetParamValue(pBuff, IDX_PARAM_RADIUS, buffInfo.m_param[0]);
			pBuff->SetIntervalTime(buffInfo.m_param[1]);
			return true;
		}
		return false;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		SkillPart* pSkillPart = dynamic_cast<SkillPart*>(pRecv->GetPart(PART_SKILL));
		if (pSkillPart == nullptr)
		{
			return;
		}

		float radius = GetParamValue(pBuff, IDX_PARAM_RADIUS) / 1000.0f;
		uint32_t skillId = GetParamValue(pBuff, IDX_PARAM_SKILL_ID);

		Scene* pScene = pRecv->GetScene();
		if (pScene)
		{
			std::list<CharIDType> cidLst;
			pScene->FindCreatureInCircle(cidLst, pRecv->GetPos(), radius);
			for(auto iter = cidLst.begin(); iter != cidLst.end(); iter++)
			{
				CharIDType cid = *iter;
				Creature* pTarget = pScene->GetCreature(cid);

				if (pTarget && !pTarget->IsDead())
				{
					if (pTarget->CreatureKind() == CREATURE_PLAYER
							|| pTarget->CreatureKind() == CREATURE_MONSTER
							|| pTarget->CreatureKind() == CREATURE_NPC
							|| pTarget->CreatureKind() == CREATURE_SUMMON)
					{
						if (pSkillPart->IsCanBeAttackBySkill(skillId, cid))
						{
							pSkillPart->AddStateBag(skillId, pBuff->GetSkillLevel(), pTarget);
						}
					}
				}
			}
		}
	}
};


/*
=======================================================================================================================
说明
BuffLogic_050_RectHaleEffect ;
功能描述：50
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_050_RectHaleEffect : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_RECT_WIDTH = 0, IDX_PARAM_RECT_HEIGHT = 1, IDX_PARAM_SKILL_ID = 2, };
	BuffLogic_050_RectHaleEffect(){};
	~BuffLogic_050_RectHaleEffect(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_SKILL_ID, param);

		if (buffInfo.m_param.size() >= 3)
		{
			SetParamValue(pBuff, IDX_PARAM_RECT_HEIGHT, buffInfo.m_param[0]);
			SetParamValue(pBuff, IDX_PARAM_RECT_WIDTH, buffInfo.m_param[1]);
			pBuff->SetIntervalTime(buffInfo.m_param[2]);
			return true;
		}
		return false;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		SkillPart* pSkillPart = dynamic_cast<SkillPart*>(pRecv->GetPart(PART_SKILL));
		if (pSkillPart == nullptr)
		{
			return;
		}

		float width = GetParamValue(pBuff, IDX_PARAM_RECT_WIDTH) / 1000.0f;
		float height = GetParamValue(pBuff, IDX_PARAM_RECT_HEIGHT) / 1000.0f;
		uint32_t skillId = GetParamValue(pBuff, IDX_PARAM_SKILL_ID);

		Scene* pScene = pRecv->GetScene();
		if (pScene)
		{
			std::list<CharIDType> cidLst;
			pScene->FindCreatureInRect(cidLst, pRecv->GetPos(), pRecv->GetDir(), height, width);
			for(auto iter = cidLst.begin(); iter != cidLst.end(); iter++)
			{
				CharIDType cid = *iter;
				Creature* pTarget = pScene->GetCreature(cid);

				if (pTarget && !pTarget->IsDead())
				{
					if (pTarget->CreatureKind() == CREATURE_PLAYER
							|| pTarget->CreatureKind() == CREATURE_MONSTER
							|| pTarget->CreatureKind() == CREATURE_NPC
							|| pTarget->CreatureKind() == CREATURE_SUMMON)
					{
						if (pSkillPart->IsCanBeAttackBySkill(skillId, cid))
						{
							pSkillPart->AddStateBag(skillId, pBuff->GetSkillLevel(), pTarget);
						}
					}
				}
			}
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_053_XiXue;
功能描述：53
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_053_XiXue : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_XIXUE_PERCENT = 0, };
	BuffLogic_053_XiXue(){};
	~BuffLogic_053_XiXue(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_XIXUE_PERCENT, param);

		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		int32_t percent = GetParamValue(pBuff, IDX_PARAM_XIXUE_PERCENT);
		int32_t value = (int32_t)pBuff->GetBuffBag()->GetBuffPart()->GetBuffEventParam().m_damagedValue * percent / 10000.0f;

		if (value > 0)
		{
			pRecv->AddAttr(C_HP, value, true);

			UseBuffResult	useResult;
			useResult.set_skillid(pBuff->GetSkillId());
			useResult.set_usercid(pBuff->GetSenderId());
			useResult.set_buffid(pBuff->GetEffectType());
			useResult.set_buffbaginstid(0);
			useResult.set_buffbagid(0);

			UseBuffResult::Target *pTarget = useResult.add_targets();
			pTarget->set_targetcid(pRecv->GetCid());
			pTarget->set_bedead(pRecv->IsDead());
			Attr* pAttr = pTarget->add_creatureattr();
			pAttr->set_attrnum(pRecv->GetAttrNum(C_HP));
			pAttr->set_attrvalue(pRecv->GetAttr(C_HP));

			//跳字表现数据
			DigPerfor* pdigti = pTarget->add_digperfors();
			pdigti->set_type(DigPerfor_Type_addHp);
			pdigti->set_value(value);

			pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_054_ZiBao;
功能描述：54
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_054_ZiBao : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_SELF_DAMAGE_PERCENT = 0, IDX_PARAM_TARGET_DAMAGE_VALUE = 1, IDX_PARAM_RADIUS = 2, };
	BuffLogic_054_ZiBao(){};
	~BuffLogic_054_ZiBao(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_TARGET_DAMAGE_VALUE, param);
		if (buffInfo.m_param.size() >= 2)
		{
			SetParamValue(pBuff, IDX_PARAM_SELF_DAMAGE_PERCENT, buffInfo.m_param[0]);
			SetParamValue(pBuff, IDX_PARAM_RADIUS, buffInfo.m_param[1]);
		}
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		Scene* pScene = pRecv->GetScene();
		if (pScene)
		{
			std::list<uint64_t> cidList;
			float radius = GetParamValue(pBuff, IDX_PARAM_RADIUS) / 1000.0f;

			pScene->FindCreatureInCircle(cidList, pRecv->GetPos(), radius);

			for (auto it = cidList.begin(); it != cidList.end(); it++)
			{
				auto cid = *it;
				Creature* pCreature = pScene->GetCreature(cid);
				if (pCreature && pCreature->GetCid() != pRecv->GetCid())
				{
					int64_t hp = GetParamValue(pBuff, IDX_PARAM_TARGET_DAMAGE_VALUE);
					pCreature->AddAttr(C_HP, -hp, true);
				}
			}

			if (pRecv)
			{
				int64_t hp = pRecv->GetAttr(C_HP);
				hp = hp * GetParamValue(pBuff, IDX_PARAM_SELF_DAMAGE_PERCENT) / 10000.0f;
				pRecv->AddAttr(C_HP, -hp, true);
			}
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_051_ChaoFeng;
功能描述：51
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_051_ChaoFeng : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_051_ChaoFeng(){};
	~BuffLogic_051_ChaoFeng(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead() || pRecv->GetScene() == nullptr)
		{
			return;
		}

		pRecv->AddBuffState(CreatureBuffStateIndex::CREATURE_BUFF_STATE_CHAOFENG);

		Creature* pSender = pRecv->GetScene()->GetCreature(pBuff->GetSenderId());
		if (pSender == nullptr) return;

		if (pRecv->CreatureKind() == CREATURE_MONSTER
				&& (dynamic_cast<Monster*>(pRecv))->GetParentMonsterType() == PARENT_MONSTER_TYPE_MONSTER)
		{
			if (!pRecv->IsFriendSide(pSender))
			{
				if (pRecv->GetAiData()) pRecv->GetAiData()->AddHateTarget(pSender->GetCid(), 100000, 0);
			}
		}

		if (pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (!pRecv->IsFriendSide(pSender))
			{
				if (pRecv->GetAiData()) pRecv->GetAiData()->AddHateTarget(pSender->GetCid(), 100000, 0);
			}
		}
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CreatureBuffStateIndex::CREATURE_BUFF_STATE_CHAOFENG);

		Creature* pSender = pRecv->GetScene()->GetCreature(pBuff->GetSenderId());
		if (pSender == nullptr) return;

		if (pRecv->CreatureKind() == CREATURE_MONSTER
				&& (dynamic_cast<Monster*>(pRecv))->GetParentMonsterType() == PARENT_MONSTER_TYPE_MONSTER)
		{
			if (!pRecv->IsFriendSide(pSender))
			{
				if (pRecv->GetAiData()) pRecv->GetAiData()->AddHateTarget(pSender->GetCid(), -100000, 0);
			}
		}

		if (pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (!pRecv->IsFriendSide(pSender))
			{
				if (pRecv->GetAiData()) pRecv->GetAiData()->AddHateTarget(pSender->GetCid(), -100000, 0);
			}
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_052_AddHate;
功能描述：52
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_052_AddHate : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_ADD_HATE = 0, };
	BuffLogic_052_AddHate(){};
	~BuffLogic_052_AddHate(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_ADD_HATE, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead() || pRecv->GetScene() == nullptr)
		{
			return;
		}

		int32_t param = GetParamValue(pBuff, IDX_PARAM_ADD_HATE);

		Creature* pSender = pRecv->GetScene()->GetCreature(pBuff->GetSenderId());
		if (pSender == nullptr) return;

		if (pRecv->CreatureKind() == CREATURE_MONSTER || pRecv->CreatureKind() == CREATURE_NPC)
		{
			if (!pRecv->IsFriendSide(pSender))
			{
				if (pRecv->GetAiData())
				{
					pRecv->GetAiData()->ClearHateListDeadAndSort();
					if (!pRecv->GetAiData()->GetHateList().IsEmpty())
					{
						HateTargetData &pData = pRecv->GetAiData()->GetHateList().GetHateList().front();
						pRecv->GetAiData()->AddHateTarget(pSender->GetCid(), pData.m_hateValue + param, 0);
					}
					else
					{
						pRecv->GetAiData()->AddHateTarget(pSender->GetCid(), param, 0);
					}
				}
			}
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_055_FangYing;
功能描述：55
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_055_FangYing : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_055_FangYing(){};
	~BuffLogic_055_FangYing(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead() || pRecv->GetScene() == nullptr)
		{
			return;
		}

		pRecv->AddBuffState(CreatureBuffStateIndex::CREATURE_BUFF_STATE_SEEINVISIBLE);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CreatureBuffStateIndex::CREATURE_BUFF_STATE_SEEINVISIBLE);
	}
};

/*
=======================================================================================================================
说明
BuffLogic_056_XiMo;
功能描述：56
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_056_XiMo : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_MP_PERCENT = 0, };
	BuffLogic_056_XiMo(){};
	~BuffLogic_056_XiMo(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_MP_PERCENT, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead() && pRecv->GetScene() == nullptr)
		{
			return;
		}

		float percent = GetParamValue(pBuff, IDX_PARAM_MP_PERCENT) / 10000.0f;
		Creature* pSender = pRecv->GetScene()->GetCreature(pBuff->GetSenderId());
		if (pSender)
		{
			int value = pRecv->GetAttr(C_MP) * percent;
			pRecv->AddAttr(C_MP, -value, true);
			pSender->AddAttr(C_MP, value, true);
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_057_FangShang;
功能描述：57
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_057_FangShang : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_PERCENT = 0, };
	BuffLogic_057_FangShang(){};
	~BuffLogic_057_FangShang(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_PERCENT, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead() && pRecv->GetScene() == nullptr)
		{
			return;
		}

		float percent = GetParamValue(pBuff, IDX_PARAM_PERCENT) / 10000.0f;
		Creature* pAttackTarget = pRecv->GetScene()->GetCreature(pBuff->GetBuffBag()->GetBuffPart()->GetBuffEventParam().m_targetCid);
		if (pAttackTarget && !pAttackTarget->IsDead())
		{
			int value = pBuff->GetBuffBag()->GetBuffPart()->GetBuffEventParam().m_damagedValue * percent;
			pAttackTarget->AddAttr(C_HP, -value, true);

			UseBuffResult	useResult;
			useResult.set_skillid(pBuff->GetSkillId());
			useResult.set_usercid(pBuff->GetSenderId());
			useResult.set_buffid(pBuff->GetEffectType());
			useResult.set_buffbaginstid(0);
			useResult.set_buffbagid(0);

			UseBuffResult::Target *pTarget = useResult.add_targets();
			pTarget->set_targetcid(pAttackTarget->GetCid());
			pTarget->set_bedead(pAttackTarget->IsDead());
			Attr* pAttr = pTarget->add_creatureattr();
			pAttr->set_attrnum(pAttackTarget->GetAttrNum(C_HP));
			pAttr->set_attrvalue(pAttackTarget->GetAttr(C_HP));

			//跳字表现数据
			DigPerfor* pdigti = pTarget->add_digperfors();
			pdigti->set_type(DigPerfor_Type_reduceHp);
			pdigti->set_value(value);

			pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
		}

	}
};

/*
=======================================================================================================================
说明
BuffLogic_058_BOSSSheild;
功能描述：58
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_058_BOSSSheild : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_HP_SHIELD = 0, IDX_PARAM_SELF_DAMAGE_PERCENT = 1, IDX_PARAM_OTHER_DAMAGE_PERCENT = 2,
		IDX_PARAM_RADIUS = 3, IDX_PARAM_HP_SHIELD_SAVE = 4, IDX_PARAM_SKILL_ID = 5, IDX_PARAM_MAX = 6};
	BuffLogic_058_BOSSSheild(){};
	~BuffLogic_058_BOSSSheild(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		pBuff->SetParamSize(IDX_PARAM_MAX);
		if (param < 0)
		{
			param = 0;
		}

		SetParamValue(pBuff, IDX_PARAM_HP_SHIELD, param);
		SetParamValue(pBuff, IDX_PARAM_HP_SHIELD_SAVE, param);
		if (buffInfo.m_param.size() >= 4)
		{
			SetParamValue(pBuff, IDX_PARAM_SELF_DAMAGE_PERCENT, buffInfo.m_param[0]);
			SetParamValue(pBuff, IDX_PARAM_OTHER_DAMAGE_PERCENT, buffInfo.m_param[1]);
			SetParamValue(pBuff, IDX_PARAM_RADIUS, buffInfo.m_param[2]);
			SetParamValue(pBuff, IDX_PARAM_SKILL_ID, buffInfo.m_param[3]);
			return true;
		}

		return false;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead())
		{
			return;
		}

		pRecv->AddBuffState(CREATURE_BUFF_STATE_HP_SHIELD);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		pRecv->RemoveBuffState(CREATURE_BUFF_STATE_HP_SHIELD);

		if (pRecv->IsDead() || pRecv->GetScene() == nullptr) return;

		int32_t skillId = GetParamValue(pBuff, IDX_PARAM_SKILL_ID);
		if (skillId > 0)
		{
			SkillPart* pSkillPart = dynamic_cast<SkillPart*>(pRecv->GetPart(PART_SKILL));
			if (pSkillPart)
			{
				pSkillPart->AddStateBag((uint32_t)skillId, 1, pRecv);
			}
		}

		int32_t hpShield = GetParamValue(pBuff, IDX_PARAM_HP_SHIELD);

		UseBuffResult	useResult;
		useResult.set_skillid(pBuff->GetSkillId());
		useResult.set_usercid(pBuff->GetSenderId());
		useResult.set_buffid(pBuff->GetEffectType());
		useResult.set_buffbaginstid(0);
		useResult.set_buffbagid(0);

		float radius = GetParamValue(pBuff, IDX_PARAM_RADIUS) / 1000.0f;

		if (hpShield > 0)
		{
			int64_t otherDamage = (GetParamValue(pBuff, IDX_PARAM_HP_SHIELD_SAVE) - hpShield) * (GetParamValue(pBuff, IDX_PARAM_OTHER_DAMAGE_PERCENT) / 10000.0f);
			std::list<CharIDType> clist;
			pRecv->GetScene()->FindCreatureInCircle(clist, pRecv->GetPos(), radius);
			for (auto it = clist.begin(); it != clist.end(); it++)
			{
				Creature* pCreature = pRecv->GetScene()->GetCreature(*it);
				if (pCreature && pCreature->CreatureKind() == CREATURE_PLAYER
						&& pCreature->GetCid() != pRecv->GetCid() && !pCreature->IsDead())
				{
					pCreature->AddAttr(C_HP, (int32_t)(-otherDamage), true);

					UseBuffResult::Target *pTarget = useResult.add_targets();
					pTarget->set_targetcid(pCreature->GetCid());
					pTarget->set_bedead(pCreature->IsDead());
					Attr* pAttr = pTarget->add_creatureattr();
					pAttr->set_attrnum(pCreature->GetAttrNum(C_HP));
					pAttr->set_attrvalue(pCreature->GetAttr(C_HP));

					//跳字表现数据
					DigPerfor* pdigti = pTarget->add_digperfors();
					pdigti->set_type(DigPerfor_Type_reduceHp);
					pdigti->set_value(otherDamage);
				}
			}
		}
		else
		{
			int64_t selfDamage = GetParamValue(pBuff, IDX_PARAM_HP_SHIELD_SAVE) * (GetParamValue(pBuff, IDX_PARAM_SELF_DAMAGE_PERCENT) / 10000.0f);
			pRecv->AddAttr(C_HP, (int32_t)(-selfDamage), true);

			UseBuffResult::Target *pTarget = useResult.add_targets();
			pTarget->set_targetcid(pRecv->GetCid());
			pTarget->set_bedead(pRecv->IsDead());
			Attr* pAttr = pTarget->add_creatureattr();
			pAttr->set_attrnum(pRecv->GetAttrNum(C_HP));
			pAttr->set_attrvalue(pRecv->GetAttr(C_HP));

			//跳字表现数据
			DigPerfor* pdigti = pTarget->add_digperfors();
			pdigti->set_type(DigPerfor_Type_reduceHp);
			pdigti->set_value(selfDamage);
		}

		pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
	}

	//damage 是个负数
	virtual void OnEvent_ReduceDamage(BuffEffectInfo* pBuff, Creature* pRecv, Creature* pAttack, uint32_t skillId, int32_t &damage) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (damage <= 0)
		{
			return;
		}

		int32_t hpShield = GetParamValue(pBuff, IDX_PARAM_HP_SHIELD);

		if (hpShield > damage)
		{
			hpShield -= damage;
			damage = 0;
		}
		else
		{
			damage -= hpShield;
			hpShield = 0;
		}

		SetParamValue(pBuff, IDX_PARAM_HP_SHIELD, hpShield);

		if (hpShield <= 0)
		{
			pBuff->GetBuffBag()->BuffEffect_OnEffectFadeOut();
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_059_FangShang;
功能描述：59 针对特定玩家的反伤
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_059_FangShang : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM = 0, };
	BuffLogic_059_FangShang(){};
	~BuffLogic_059_FangShang(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM, param);
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead() || pBuff->GetBuffBag()->GetBuffPart()->GetBuffEventParam().m_targetCid != pBuff->GetSenderId() || pRecv->GetScene() == nullptr)
		{
			return;
		}

		Creature* pAttackTarget = pRecv;
		if (pAttackTarget && !pAttackTarget->IsDead())
		{
			int value = GetParamValue(pBuff, IDX_PARAM);
			pAttackTarget->AddAttr(C_HP, -value, true);

			UseBuffResult	useResult;
			useResult.set_skillid(pBuff->GetSkillId());
			useResult.set_usercid(pBuff->GetSenderId());
			useResult.set_buffid(pBuff->GetEffectType());
			useResult.set_buffbaginstid(0);
			useResult.set_buffbagid(0);

			UseBuffResult::Target *pTarget = useResult.add_targets();
			pTarget->set_targetcid(pAttackTarget->GetCid());
			pTarget->set_bedead(pAttackTarget->IsDead());
			Attr* pAttr = pTarget->add_creatureattr();
			pAttr->set_attrnum(pAttackTarget->GetAttrNum(C_HP));
			pAttr->set_attrvalue(pAttackTarget->GetAttr(C_HP));

			//跳字表现数据
			DigPerfor* pdigti = pTarget->add_digperfors();
			pdigti->set_type(DigPerfor_Type_reduceHp);
			pdigti->set_value(value);

			pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
		}

	}
};

/*
=======================================================================================================================
说明
BuffLogic_060_FengDan;
功能描述：60 分担伤害
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_060_FengDan : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM_DAMAGE = 0, DIX_PARAM_RADIUS = 1 };
	BuffLogic_060_FengDan(){};
	~BuffLogic_060_FengDan(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		SetParamValue(pBuff, IDX_PARAM_DAMAGE, param);
		if (buffInfo.m_param.size() > 0)
		{
			SetParamValue(pBuff, DIX_PARAM_RADIUS, buffInfo.m_param[0]);
		}
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{

	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		if (pRecv->IsDead() || pRecv->GetScene() == nullptr)
		{
			return;
		}

		float flength = GetParamValue(pBuff, DIX_PARAM_RADIUS) / 1000.0f;
		std::list<CharIDType> clist;
		pRecv->GetScene()->FindCreatureInCircle(clist, pRecv->GetPos(), flength);
		std::vector<Creature*> vec;
		for(auto it = clist.begin(); it != clist.end(); it++)
		{
			Creature* pCreature = pRecv->GetScene()->GetCreature(*it);
			if (pCreature && !pCreature->IsDead()
					&& (pCreature->CreatureKind() == CREATURE_PLAYER ||
							pCreature->CreatureKind() == CREATURE_MONSTER ||
							pCreature->CreatureKind() == CREATURE_NPC)
					&& pRecv->IsFriendSide(pCreature))
			{
				vec.push_back(pCreature);
			}
		}

		if (vec.empty()) return;

		int damage = GetParamValue(pBuff, IDX_PARAM_DAMAGE) / vec.size();

		for(auto it = vec.begin(); it != vec.end(); it++)
		{
			Creature* pCreature = *it;
			pCreature->AddAttr(C_HP, -damage, true);

			UseBuffResult	useResult;
			useResult.set_skillid(pBuff->GetSkillId());
			useResult.set_usercid(pBuff->GetSenderId());
			useResult.set_buffid(pBuff->GetEffectType());
			useResult.set_buffbaginstid(0);
			useResult.set_buffbagid(0);

			UseBuffResult::Target *pTarget = useResult.add_targets();
			pTarget->set_targetcid(pCreature->GetCid());
			pTarget->set_bedead(pCreature->IsDead());
			Attr* pAttr = pTarget->add_creatureattr();
			pAttr->set_attrnum(pCreature->GetAttrNum(C_HP));
			pAttr->set_attrvalue(pCreature->GetAttr(C_HP));

			//跳字表现数据
			DigPerfor* pdigti = pTarget->add_digperfors();
			pdigti->set_type(DigPerfor_Type_reduceHp);
			pdigti->set_value(damage);

			pRecv->BroadCastData(EMODULE_ID_BUFF, LOGIC_TO_CLIENT_BUFF_RESULT_BROADCAST, (ProtoBufBase*)&useResult, true);
		}
	}
};

/*
=======================================================================================================================
说明
BuffLogic_128_DisMount;
功能描述：128 下坐骑或禁止召唤坐骑
参数描述：	0个参数
=======================================================================================================================
*/
class BuffLogic_128_DisMount : public IBuffLogic
{
public:
	enum BuffEffectParamIndex { IDX_PARAM = 0 };
	BuffLogic_128_DisMount(){};
	~BuffLogic_128_DisMount(){};

	int32_t GetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index) const
	{
		return pBuff->GetParamByIndex(index);
	};

	void SetParamValue(BuffEffectInfo* pBuff, BuffEffectParamIndex index, int32_t value) const
	{
		pBuff->SetParamByIndex(index, (int32_t)value);
	}

	virtual bool InitFromData(const BuffEffectCfgInfo& buffInfo, BuffBagEffectInfo* pBuffBag, BuffEffectInfo* pBuff, uint64_t senderCid, Creature* pRecv, int32_t param)
	{
		return true;
	}

	virtual void OnEvent_Active(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}

		Player* pPlayer = dynamic_cast<Player*>(pRecv);
		if (pPlayer)
		{
			HorsePart* pHorsePart = dynamic_cast<HorsePart*>(pPlayer->GetPart(PART_HORSE));
			if (pHorsePart)
			{
				pHorsePart->DismountHorse();
			}
		}

		pRecv->AddBuffState(CREATURE_BUFF_DISMOUNT);
	}

	virtual void OnEvent_FadeOut(BuffEffectInfo* pBuff, Creature* pRecv) const
	{
		if (!pBuff || !pRecv)
		{
			return;
		}
		pRecv->RemoveBuffState(CREATURE_BUFF_DISMOUNT);
	}
};
